Переглянути джерело

Do not use the fixed list if it is empty.

Ioannis Koutras 13 роки тому
батько
коміт
2f18c244f5
1 змінених файлів з 6 додано та 4 видалено
  1. 6 4
      test.c

+ 6 - 4
test.c

@@ -50,10 +50,12 @@ void *custom_malloc(heap_t* heap, size_t size) {
 				current_maptable_node = current_maptable_node->next;
 			}
 		}
-		ptr = current_maptable_node->fixed_list_head;
-		current_maptable_node->fixed_list_head = ptr->next;
-		set_requested_size(ptr, size);
-		markInUse(ptr);
+		if(current_maptable_node->fixed_list_head != NULL) {
+			ptr = current_maptable_node->fixed_list_head;
+			current_maptable_node->fixed_list_head = ptr->next;
+			set_requested_size(ptr, size);
+			markInUse(ptr);
+		}
 	}
 
 	if(ptr == NULL) {