Browse Source

timers_exit may be called without timers_init

bel 11 năm trước cách đây
mục cha
commit
d08f534309
1 tập tin đã thay đổi với 4 bổ sung2 xóa
  1. 4 2
      src/timer.inl

+ 4 - 2
src/timer.inl

@@ -124,6 +124,8 @@ static int timers_init(struct mg_context * ctx)
 
 static void timers_exit(struct mg_context * ctx)
 {
-    (void) pthread_mutex_destroy(&ctx->timers->mutex);
-    mg_free(ctx->timers);
+    if (ctx->timers) {
+        (void) pthread_mutex_destroy(&ctx->timers->mutex);
+        mg_free(ctx->timers);
+    }
 }