Don't blindly strdup() optional arguments
authorcoderain <coderain@sdf.org>
Wed, 15 Nov 2017 04:19:45 +0000 (05:19 +0100)
committercoderain <coderain@sdf.org>
Wed, 15 Nov 2017 04:19:45 +0000 (05:19 +0100)
kernel/src/sync.c

index c8cc3b860efba4cce051f4bb62606e5b450e59be..fa91b46dc04b660408f3efcb8e8e6c1e0f007bfd 100644 (file)
@@ -119,7 +119,7 @@ sysret_t syscall_create_semaphore(const char *name, dword_t init_count, dword_t
 
     init_semaphore(semaphore, init_count, max_count);
 
-    semaphore->header.name = strdup(safe_name);
+    semaphore->header.name = name ? strdup(safe_name) : NULL;
     semaphore->header.type = OBJECT_SEMAPHORE;
 
     dword_t ret = create_object(&semaphore->header);