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

disallow appending NULL elements to queue

cecylia 7 лет назад
Родитель
Сommit
cc4b2763df
1 измененных файлов с 4 добавлено и 0 удалено
  1. 4 0
      relay_station/util.c

+ 4 - 0
relay_station/util.c

@@ -75,6 +75,10 @@ queue *init_queue(){
  * Function to append a struct to the end of a list
  */
 void enqueue(queue *list, void *data){
+    //Do not allow appending NULL data
+    if(data == NULL){
+        return;
+    }
     element *new_elem = emalloc(sizeof(element));
     new_elem->data = data;
     new_elem->next = NULL;