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

Fix for bug 774. Check malloc return before accessing pointer.


git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@775 fd59a12c-fef9-0310-b244-a6a79926bd2f
Mark Haverkamp 20 лет назад
Родитель
Сommit
4dd48bef0d
1 измененных файлов с 3 добавлено и 3 удалено
  1. 3 3
      lib/evt.c

+ 3 - 3
lib/evt.c

@@ -1850,14 +1850,14 @@ saEvtEventPublish(
 
 
 	req = malloc(sizeof(*req) + eventDataSize + pattern_size);
 	req = malloc(sizeof(*req) + eventDataSize + pattern_size);
 
 
-	patterns = (struct event_pattern *)req->led_body;
-	data_start = (void *)req->led_body + pattern_size;
-
 	if (!req) {
 	if (!req) {
 		error = SA_AIS_ERR_NO_MEMORY;
 		error = SA_AIS_ERR_NO_MEMORY;
 		goto pub_put3;
 		goto pub_put3;
 	}
 	}
 
 
+	patterns = (struct event_pattern *)req->led_body;
+	data_start = (void *)req->led_body + pattern_size;
+
 	/*
 	/*
 	 * copy everything to the request structure
 	 * copy everything to the request structure
 	 */
 	 */