Prechádzať zdrojové kódy

Fix crash if mg_start is called twice, with invalid port at first call (see #270)

bel 9 rokov pred
rodič
commit
aa4408b202
1 zmenil súbory, kde vykonal 3 pridanie a 4 odobranie
  1. 3 4
      src/civetweb.c

+ 3 - 4
src/civetweb.c

@@ -10685,6 +10685,7 @@ initialize_ssl(struct mg_context *ctx)
 	return 1;
 }
 
+
 static int
 ssl_use_pem_file(struct mg_context *ctx, const char *pem)
 {
@@ -10917,6 +10918,8 @@ uninitialize_ssl(struct mg_context *ctx)
 		for (i = 0; i < CRYPTO_num_locks(); i++) {
 			pthread_mutex_destroy(&ssl_mutexes[i]);
 		}
+		mg_free(ssl_mutexes);
+		ssl_mutexes = NULL;
 	}
 }
 #endif /* !NO_SSL */
@@ -12417,10 +12420,6 @@ free_context(struct mg_context *ctx)
 	if (ctx->ssl_ctx != NULL) {
 		SSL_CTX_free(ctx->ssl_ctx);
 	}
-	if (ssl_mutexes != NULL) {
-		mg_free(ssl_mutexes);
-		ssl_mutexes = NULL;
-	}
 #endif /* !NO_SSL */
 
 	/* Deallocate worker thread ID array */