Explorar o código

Fix coverity bug ID 5

In poll_timer_add() if you pass in a NULL for the callback function
the pointer will be dereferenced.

I have moved the check for the NULL up.



git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@1714 fd59a12c-fef9-0310-b244-a6a79926bd2f
Angus Salkeld %!s(int64=17) %!d(string=hai) anos
pai
achega
2998d698ad
Modificáronse 1 ficheiros con 5 adicións e 5 borrados
  1. 5 5
      exec/coropoll.c

+ 5 - 5
exec/coropoll.c

@@ -291,18 +291,18 @@ int poll_timer_add (
 	struct poll_instance *poll_instance;
 	struct poll_instance *poll_instance;
 	int res = 0;
 	int res = 0;
 
 
+	if (timer_handle_out == NULL) {
+		res -ENOENT;
+		goto error_exit;
+	}
+
 	res = hdb_handle_get (&poll_instance_database, handle,
 	res = hdb_handle_get (&poll_instance_database, handle,
 		(void *)&poll_instance);
 		(void *)&poll_instance);
 	if (res != 0) {
 	if (res != 0) {
 		res = -ENOENT;
 		res = -ENOENT;
-		
 		goto error_exit;
 		goto error_exit;
 	}
 	}
 
 
-	if (timer_handle_out == 0) {
-		res = -ENOENT;
-	}
-
 	timerlist_add_duration (&poll_instance->timerlist,
 	timerlist_add_duration (&poll_instance->timerlist,
 		timer_fn, data, ((unsigned long long)msec_duration) * 1000000ULL, timer_handle_out);
 		timer_fn, data, ((unsigned long long)msec_duration) * 1000000ULL, timer_handle_out);