Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 20 Oct 2005 20:33:51 GMT
From:      Todd Miller <millert@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 85616 for review
Message-ID:  <200510202033.j9KKXpIs024171@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=85616

Change 85616 by millert@millert_ibook on 2005/10/20 20:33:28

	Don't deref NULL pointer in sebsd_ss_malloc() if sebsd_malloc()
	returns NULL.  Style nits in sebsd_ss_malloc() and sebsd_ss_free().

Affected files ...

.. //depot/projects/trustedbsd/sedarwin7/src/sedarwin/sedarwin/sebsd.c#9 edit

Differences ...

==== //depot/projects/trustedbsd/sedarwin7/src/sedarwin/sedarwin/sebsd.c#9 (text+ko) ====

@@ -111,21 +111,27 @@
 
 #ifdef __APPLE__
 
-void *sebsd_ss_malloc (size_t size, int flags)
+void *
+sebsd_ss_malloc(size_t size, int flags)
 {
-  size += sizeof(size_t);
-  size_t *v = sebsd_malloc (size, flags);
-  v[0] = size;
-  return v+1;
+	size_t *vs;
+
+	size += sizeof(size_t);
+	if ((vs = sebsd_malloc(size, flags)) != NULL)
+		*vs++ = size;
+	return (vs);
 }
 
-void sebsd_ss_free (void *v)
+void
+sebsd_ss_free(void *v)
 {
-  if (v == NULL)
-    return;
+	size_t *vs = (size_t *)v;
+
+	if (vs == NULL)
+		return;
 
-  size_t *vs = (size_t *) v;
-  sebsd_free (vs-1, vs[-1]);
+	/* size of region is stored immediately before v */
+	sebsd_free(vs - 1, vs[-1]);
 }
 
 #else



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