Browse Source

Fix some issues detected by the new coverity version

bel2125 8 years ago
parent
commit
cba20289f7
2 changed files with 16 additions and 3 deletions
  1. 8 3
      src/civetweb.c
  2. 8 0
      src/timer.inl

+ 8 - 3
src/civetweb.c

@@ -13297,10 +13297,13 @@ get_rel_url_at_current_server(const char *uri, const struct mg_connection *conn)
 
 	auth_domain_check_enabled =
 	    !strcmp(conn->ctx->config[ENABLE_AUTH_DOMAIN_CHECK], "yes");
-	/* DNS is case insensitive, so use case insensitive string compare here
-	 */
+
+	if (!auth_domain_check_enabled) {
+		return 0;
+	}
+
 	server_domain = conn->ctx->config[AUTHENTICATION_DOMAIN];
-	if (!server_domain && auth_domain_check_enabled) {
+	if (!server_domain) {
 		return 0;
 	}
 	server_domain_len = strlen(server_domain);
@@ -13308,6 +13311,8 @@ get_rel_url_at_current_server(const char *uri, const struct mg_connection *conn)
 		return 0;
 	}
 
+	/* DNS is case insensitive, so use case insensitive string compare here
+	 */
 	for (i = 0; abs_uri_protocols[i].proto != NULL; i++) {
 		if (mg_strncasecmp(uri,
 		                   abs_uri_protocols[i].proto,

+ 8 - 0
src/timer.inl

@@ -166,7 +166,10 @@ timer_thread_run(void *thread_func_param)
 
 		d = timer_getcurrenttime();
 	}
+
+pthread_mutex_lock(&ctx->timers->mutex);
 	ctx->timers->timer_count = 0;
+pthread_mutex_unlock(&ctx->timers->mutex);
 }
 
 
@@ -207,7 +210,12 @@ timers_exit(struct mg_context *ctx)
 	if (ctx->timers) {
 		pthread_mutex_lock(&ctx->timers->mutex);
 		ctx->timers->timer_count = 0;
+		/* TODO: Do we really need to unlock the mutex, before 
+		 * destroying it, if it's destroyed by the thread currently
+		 * owning the mutex? */
+		pthread_mutex_unlock(&ctx->timers->mutex); 
 		(void)pthread_mutex_destroy(&ctx->timers->mutex);
 		mg_free(ctx->timers);
 	}
 }
+