From alfred@FreeBSD.org  Sun Oct 31 15:27:21 2004
Return-Path: <alfred@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id B35D816A4CE
	for <FreeBSD-gnats-submit@freebsd.org>; Sun, 31 Oct 2004 15:27:21 +0000 (GMT)
Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21])
	by mx1.FreeBSD.org (Postfix) with ESMTP id A5EDA43D31
	for <FreeBSD-gnats-submit@freebsd.org>; Sun, 31 Oct 2004 15:27:21 +0000 (GMT)
	(envelope-from alfred@FreeBSD.org)
Received: from freefall.freebsd.org (alfred@localhost [127.0.0.1])
	by freefall.freebsd.org (8.12.11/8.12.11) with ESMTP id i9VFRL31044049
	for <FreeBSD-gnats-submit@freebsd.org>; Sun, 31 Oct 2004 15:27:21 GMT
	(envelope-from alfred@freefall.freebsd.org)
Received: (from alfred@localhost)
	by freefall.freebsd.org (8.12.11/8.12.11/Submit) id i9VFRLtk044048;
	Sun, 31 Oct 2004 15:27:21 GMT
	(envelope-from alfred)
Message-Id: <200410311527.i9VFRLtk044048@freefall.freebsd.org>
Date: Sun, 31 Oct 2004 15:27:21 GMT
From: Alfred Perlstein <alfred@FreeBSD.org>
Reply-To: Alfred Perlstein <alfred@FreeBSD.org>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: patch for ports/sdl12 malloc bug.
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         73353
>Category:       ports
>Synopsis:       patch for devel/sdl12 malloc bug.
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    freebsd-ports-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Oct 31 15:30:31 GMT 2004
>Closed-Date:    Sat Nov 06 21:21:59 GMT 2004
>Last-Modified:  Sun Nov  7 00:00:43 GMT 2004
>Originator:     Alfred Perlstein
>Release:        FreeBSD 4.10-STABLE i386
>Organization:
RED Inc
>Environment:
System: FreeBSD freefall.freebsd.org 4.10-STABLE FreeBSD 4.10-STABLE #13: Fri May 28 21:29:54 PDT 2004 kensmith@freefall.freebsd.org:/c/src/sys/compile/FREEFALL i386


	
>Description:

If you don't have joysticks, then SDL will free(3) already free(3)'d
memory and screw up the heap.

David Xu pinned down a problem to this double/incorrect free(3).

This patch I wrote seems to fix it.


>How-To-Repeat:
Run an SDL linked program under valgrind without any joysticks present
in the system.
>Fix:

Index: files/patch-al
===================================================================
RCS file: files/patch-al
diff -N files/patch-al
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ files/patch-al	31 Oct 2004 15:10:31 -0000
@@ -0,0 +1,10 @@
+--- src/joystick/bsd/SDL_sysjoystick.c	Wed Feb 18 09:22:01 2004
++++ src/joystick/bsd/SDL_sysjoystick.c	Sun Oct 31 06:55:00 2004
+@@ -160,6 +160,7 @@
+ 			SDL_numjoysticks++;
+ 		} else {
+ 			free(joynames[nj.index]);
++			joynames[nj.index] = NULL;
+ 		}
+ 	}
+ 	for (i = 0; i < MAX_JOY_JOYS; i++) {



>Release-Note:
>Audit-Trail:

From: Pav Lucistnik <pav@FreeBSD.org>
To: freebsd-gnats-submit@FreeBSD.org, alfred@FreeBSD.org
Cc:  
Subject: Re: ports/73353: patch for devel/sdl12 malloc bug.
Date: Sat, 06 Nov 2004 22:03:59 +0100

 The port is unmaintainer (open for anyone to commit) and you're listed
 in ports' access file. Any reason why not commit this patch directly?
 
 -- 
 Pav Lucistnik <pav@oook.cz>
               <pav@FreeBSD.org>
 
 Just because you're an angel doesn't mean you have to be a fool.
State-Changed-From-To: open->closed 
State-Changed-By: pav 
State-Changed-When: Sat Nov 6 21:21:24 GMT 2004 
State-Changed-Why:  
Close and disregard my followup, I see Alfred committed this 
already. 

Pointed out by:	arvedian 

http://www.freebsd.org/cgi/query-pr.cgi?pr=73353 

From: Alfred Perlstein <alfred@freebsd.org>
To: Pav Lucistnik <pav@FreeBSD.org>
Cc: freebsd-gnats-submit@FreeBSD.org
Subject: Re: ports/73353: patch for devel/sdl12 malloc bug.
Date: Sat, 6 Nov 2004 15:53:42 -0800

 * Pav Lucistnik <pav@FreeBSD.org> [041106 13:04] wrote:
 > The port is unmaintainer (open for anyone to commit) and you're listed
 > in ports' access file. Any reason why not commit this patch directly?
 
 Done, wasn't sure of the protocol.
 
 -- 
 - Alfred Perlstein
 - Research Engineering Development Inc.
 - email: bright@mu.org cell: 408-480-4684
>Unformatted:
