Hi,
drmStrdup() doesn't check for an allocation failure. I attached a patch
that also tries to improve readability of the code. Feel free to
disagree on that :)

I realize the chances of drmStrdup() failing are probably low, but it
should be corrected anyway.

Regards,
Tilman
Index: libdrm/xf86drm.c
===================================================================
RCS file: /cvs/dri/drm/libdrm/xf86drm.c,v
retrieving revision 1.53
diff -u -r1.53 xf86drm.c
--- libdrm/xf86drm.c    29 Nov 2005 09:50:47 -0000      1.53
+++ libdrm/xf86drm.c    29 Nov 2005 19:27:46 -0000
@@ -164,12 +164,15 @@
 /* drmStrdup can't use strdup(3), since it doesn't call _DRM_MALLOC... */
 static char *drmStrdup(const char *s)
 {
-    char *retval = NULL;
+    char *retval;
+
+    if (!s) return NULL;
+
+    retval = _DRM_MALLOC(strlen(s)+1);
+    if (!retval) return NULL;
+
+    strcpy(retval, s);
 
-    if (s) {
-       retval = _DRM_MALLOC(strlen(s)+1);
-       strcpy(retval, s);
-    }
     return retval;
 }
 

Attachment: pgpvy3nfQougT.pgp
Description: PGP signature

Reply via email to