PERFORCE change 85616 for review

Todd Miller millert at FreeBSD.org
Thu Oct 20 20:33:51 GMT 2005


http://perforce.freebsd.org/chv.cgi?CH=85616

Change 85616 by millert at 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
To Unsubscribe: send mail to majordomo at trustedbsd.org
with "unsubscribe trustedbsd-cvs" in the body of the message



More information about the trustedbsd-cvs mailing list