Skip to contentSkip to conversation

don't pass a null pointer to pthread_attr_destroy

PATCH New Jeff Moyer 1 participant 1 message Sep 4, 2009 Kernel automounter

lore
Share & tools
lore

Jeff Moyer

author
#0 lore raw

PATCH 1/1 don't pass a null pointer to pthread_attr_destroy

Hi, Ian,

pthread_attr_destroy will dereference the pointer that is passed in. Since we can get here with a NULL pattrs, we better check for that.

Cheers,
Jeff

daemon/state.c +2 -1
index 71af46a..2eeb4bf 100644
@@ -1198,7 +1198,8 @@ int st_start_handler(void)
 
 	status = pthread_create(&thid, pattrs, st_queue_handler, NULL);
 
-	pthread_attr_destroy(pattrs);
+	if (pattrs)
+		pthread_attr_destroy(pattrs);
 
 	return !status;
 }