Browse Source

Move declaration to top of block (old compiler support)

This is still required for Visual Studio 2012.
Probably VS2012 support can be skipped soon.
bel2125 3 years ago
parent
commit
26ff105268
1 changed files with 5 additions and 2 deletions
  1. 5 2
      src/civetweb.c

+ 5 - 2
src/civetweb.c

@@ -3616,12 +3616,13 @@ mg_construct_local_link(const struct mg_connection *conn,
 		int port = (define_port > 0) ? define_port : ri->server_port;
 		int port = (define_port > 0) ? define_port : ri->server_port;
 		int default_port = 80;
 		int default_port = 80;
 		char *uri_encoded;
 		char *uri_encoded;
+		size_t uri_encoded_len;
 
 
 		if (uri == NULL) {
 		if (uri == NULL) {
 			return -1;
 			return -1;
 		}
 		}
 
 
-		size_t uri_encoded_len = strlen(uri) * 3 + 1;
+		uri_encoded_len = strlen(uri) * 3 + 1;
 		uri_encoded = (char *)mg_malloc_ctx(uri_encoded_len, conn->phys_ctx);
 		uri_encoded = (char *)mg_malloc_ctx(uri_encoded_len, conn->phys_ctx);
 		if (uri_encoded == NULL) {
 		if (uri_encoded == NULL) {
 			return -1;
 			return -1;
@@ -15225,10 +15226,12 @@ handle_request(struct mg_connection *conn)
 
 
 		/* Path + server root */
 		/* Path + server root */
 		size_t buflen = UTF8_PATH_MAX * 2 + 2;
 		size_t buflen = UTF8_PATH_MAX * 2 + 2;
+		char *new_path;
+
 		if (ri->query_string) {
 		if (ri->query_string) {
 			buflen += strlen(ri->query_string);
 			buflen += strlen(ri->query_string);
 		}
 		}
-		char *new_path = (char *)mg_malloc_ctx(buflen, conn->phys_ctx);
+		new_path = (char *)mg_malloc_ctx(buflen, conn->phys_ctx);
 		if (!new_path) {
 		if (!new_path) {
 			mg_send_http_error(conn, 500, "out or memory");
 			mg_send_http_error(conn, 500, "out or memory");
 		} else {
 		} else {