ports/73353: patch for ports/sdl12 malloc bug.

Alfred Perlstein alfred at FreeBSD.org
Sun Oct 31 15:30:32 UTC 2004


>Number:         73353
>Category:       ports
>Synopsis:       patch for ports/sdl12 malloc bug.
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Oct 31 15:30:31 GMT 2004
>Closed-Date:
>Last-Modified:
>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 at 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:
>Unformatted:



More information about the freebsd-ports-bugs mailing list