summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Jackson <ajax@nwnk.net>2005-11-29 20:02:34 +0000
committerAdam Jackson <ajax@nwnk.net>2005-11-29 20:02:34 +0000
commit48198970ce449165fe1c7294108ca3afc775563d (patch)
tree57d5f71dcab103e0d5c16b1ed4b398920a39a063
parent7ede209ce0cbbc65f79d02e2cc43cfcb3abb6e99 (diff)
Error checking for drmStrdup (Tilman Sauerbeck)
-rw-r--r--libdrm/xf86drm.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/libdrm/xf86drm.c b/libdrm/xf86drm.c
index 82cf54ff..2eed8eb4 100644
--- a/libdrm/xf86drm.c
+++ b/libdrm/xf86drm.c
@@ -164,12 +164,17 @@ void drmFree(void *pt)
/* 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;
}