Explorar o código

Fix coverity issues for release 1.13

bel2125 %!s(int64=4) %!d(string=hai) anos
pai
achega
8e24345696
Modificáronse 3 ficheiros con 14 adicións e 17 borrados
  1. 1 2
      docs/README.md
  2. 3 1
      resources/coverity_check.sh
  3. 10 14
      src/civetweb.c

+ 1 - 2
docs/README.md

@@ -8,8 +8,7 @@ CivetWeb uses an [MIT license](https://github.com/civetweb/civetweb/blob/master/
 
 It can also be used by end users as a stand-alone web server. It is available as single executable, no installation is required.
 
-The current stable version is 1.12 - [release notes](https://github.com/civetweb/civetweb/blob/master/RELEASE_NOTES.md)
-1.13 is work in progress
+The current stable version is 1.13 - [release notes](https://github.com/civetweb/civetweb/blob/master/RELEASE_NOTES.md)
 
 End users can download CivetWeb at SourceForge
 [https://sourceforge.net/projects/civetweb/](https://sourceforge.net/projects/civetweb/)

+ 3 - 1
resources/coverity_check.sh

@@ -24,6 +24,8 @@ cp src/civetweb.c cov_build/src/
 cp src/main.c cov_build/src/
 cp src/md5.inl cov_build/src/
 cp src/sha1.inl cov_build/src/
+cp src/response.inl cov_build/src/
+cp src/timer.inl cov_build/src/
 cp src/handle_form.inl cov_build/src/
 cp include/civetweb.h cov_build/include/
 cp resources/Makefile.in-os cov_build/resources/
@@ -31,7 +33,7 @@ cp resources/Makefile.in-os cov_build/resources/
 cd cov_build
 
 # new scan build
-../../cov-analysis-linux64-2019.03/bin/cov-build  --dir cov-int make WITH_IPV6=1 WITH_WEBSOCKET=1 WITH_SERVER_STATS=1 WITH_EXPERIMENTAL=1
+~/cov-analysis-linux64-2019.03/bin/cov-build  --dir cov-int make WITH_IPV6=1 WITH_WEBSOCKET=1 WITH_SERVER_STATS=1 WITH_EXPERIMENTAL=1
 
 
 # pack build results for upload

+ 10 - 14
src/civetweb.c

@@ -18214,8 +18214,17 @@ mg_connect_websocket_client_impl(const struct mg_client_options *client_options,
 	                              error_buffer,
 	                              error_buffer_size);
 
+	/* Connection object will be null if something goes wrong */
 	if (conn == NULL) {
-		/* error_buffer already filled */
+		/* error_buffer should be already filled ... */
+		if (!error_buffer[0]) {
+			/* ... if not add an error message */
+			mg_snprintf(conn,
+			            NULL, /* No truncation check for ebuf */
+			            error_buffer,
+			            error_buffer_size,
+			            "Unexpected error");
+		}
 		return NULL;
 	}
 
@@ -18242,19 +18251,6 @@ mg_connect_websocket_client_impl(const struct mg_client_options *client_options,
 #pragma clang diagnostic pop
 #endif
 
-	/* Connection object will be null if something goes wrong */
-	if (conn == NULL) {
-		if (!*error_buffer) {
-			/* There should be already an error message */
-			mg_snprintf(conn,
-			            NULL, /* No truncation check for ebuf */
-			            error_buffer,
-			            error_buffer_size,
-			            "Unexpected error");
-		}
-		return NULL;
-	}
-
 	if (conn->response_info.status_code != 101) {
 		/* We sent an "upgrade" request. For a correct websocket
 		 * protocol handshake, we expect a "101 Continue" response.