Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 31 Oct 2004 15:27:21 GMT
From:      Alfred Perlstein <alfred@FreeBSD.org>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   ports/73353: patch for ports/sdl12 malloc bug.
Message-ID:  <200410311527.i9VFRLtk044048@freefall.freebsd.org>
Resent-Message-ID: <200410311530.i9VFUV5H044114@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>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@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:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200410311527.i9VFRLtk044048>