Przeglądaj źródła

Fixed a possible OOM issue.

Thomas Davis 12 lat temu
rodzic
commit
9e17943d25
1 zmienionych plików z 4 dodań i 0 usunięć
  1. 4 0
      src/civetweb.c

+ 4 - 0
src/civetweb.c

@@ -4323,6 +4323,10 @@ void mg_set_request_handler(struct mg_context *ctx, const char *uri, mg_request_
 	}
 
 	tmp_rh = (struct mg_request_handler_info *)malloc(sizeof(struct mg_request_handler_info));
+	if (tmp_rh == NULL) {
+		mg_cry(fc(ctx), "%s", "Cannot create new request handler struct, OOM");
+		return;
+	}
 	tmp_rh->uri = mg_strdup(uri);
 	tmp_rh->uri_len = strlen(uri);
 	tmp_rh->handler = handler;