more bugs
[model-checker.git] / schedule.cc
index c30b0f3..8883d2a 100644 (file)
@@ -16,9 +16,11 @@ void Scheduler::set_enabled(Thread *t, bool enabled_status) {
        int threadid=id_to_int(t->get_id());
        if (threadid>=enabled_len) {
                bool * new_enabled=(bool *)malloc(sizeof(bool)*(threadid+1));
-               memcpy(new_enabled, is_enabled, enabled_len*sizeof(bool));
                memset(&new_enabled[enabled_len], 0, (threadid+1-enabled_len)*sizeof(bool));
-               free(is_enabled);
+               if (is_enabled != NULL) {
+                       memcpy(new_enabled, is_enabled, enabled_len*sizeof(bool));
+                       free(is_enabled);
+               }
                is_enabled=new_enabled;
                enabled_len=threadid+1;
        }