summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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;
}