Просмотр исходного кода

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 17 лет назад
Родитель
Сommit
2998d698ad
1 измененных файлов с 5 добавлено и 5 удалено
  1. 5 5
      exec/coropoll.c

+ 5 - 5
exec/coropoll.c

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