@@ -145,7 +145,8 @@ bool git_http_response_is_redirect(git_http_response *response)
145145
146146void git_http_response_dispose (git_http_response * response )
147147{
148- assert (response );
148+ if (!response )
149+ return ;
149150
150151 git__free (response -> content_type );
151152 git__free (response -> location );
@@ -399,7 +400,7 @@ static int on_body(http_parser *parser, const char *buf, size_t len)
399400 return 0 ;
400401 }
401402
402- assert (ctx -> output_size >= ctx -> output_written );
403+ GIT_ASSERT (ctx -> output_size >= ctx -> output_written );
403404
404405 max_len = min (ctx -> output_size - ctx -> output_written , len );
405406 max_len = min (max_len , INT_MAX );
@@ -665,7 +666,8 @@ static int generate_request(
665666 size_t i ;
666667 int error ;
667668
668- assert (client && request );
669+ GIT_ASSERT_ARG (client );
670+ GIT_ASSERT_ARG (request );
669671
670672 git_buf_clear (& client -> request_msg );
671673 buf = & client -> request_msg ;
@@ -842,7 +844,10 @@ static int setup_hosts(
842844{
843845 int ret , diff = 0 ;
844846
845- assert (client && request && request -> url );
847+ GIT_ASSERT_ARG (client );
848+ GIT_ASSERT_ARG (request );
849+
850+ GIT_ASSERT (request -> url );
846851
847852 if ((ret = server_setup_from_url (& client -> server , request -> url )) < 0 )
848853 return ret ;
@@ -922,7 +927,7 @@ static int proxy_connect(
922927 (error = git_http_client_skip_body (client )) < 0 )
923928 goto done ;
924929
925- assert (client -> state == DONE );
930+ GIT_ASSERT (client -> state == DONE );
926931
927932 if (response .status == GIT_HTTP_STATUS_PROXY_AUTHENTICATION_REQUIRED ) {
928933 save_early_response (client , & response );
@@ -1137,7 +1142,7 @@ GIT_INLINE(int) client_read_and_parse(git_http_client *client)
11371142 * final byte when paused in a callback. Consume that byte.
11381143 * https://github.com/nodejs/http-parser/issues/97
11391144 */
1140- assert (client -> read_buf .size > parsed_len );
1145+ GIT_ASSERT (client -> read_buf .size > parsed_len );
11411146
11421147 http_parser_pause (parser , 0 );
11431148
@@ -1215,7 +1220,8 @@ int git_http_client_send_request(
12151220 git_http_response response = {0 };
12161221 int error = -1 ;
12171222
1218- assert (client && request );
1223+ GIT_ASSERT_ARG (client );
1224+ GIT_ASSERT_ARG (request );
12191225
12201226 /* If the client did not finish reading, clean up the stream. */
12211227 if (client -> state == READING_BODY )
@@ -1286,7 +1292,7 @@ int git_http_client_send_body(
12861292 git_buf hdr = GIT_BUF_INIT ;
12871293 int error ;
12881294
1289- assert (client );
1295+ GIT_ASSERT_ARG (client );
12901296
12911297 /* If we're waiting for proxy auth, don't sending more requests. */
12921298 if (client -> state == HAS_EARLY_RESPONSE )
@@ -1303,7 +1309,7 @@ int git_http_client_send_body(
13031309 server = & client -> server ;
13041310
13051311 if (client -> request_body_len ) {
1306- assert (buffer_len <= client -> request_body_remain );
1312+ GIT_ASSERT (buffer_len <= client -> request_body_remain );
13071313
13081314 if ((error = stream_write (server , buffer , buffer_len )) < 0 )
13091315 goto done ;
@@ -1326,7 +1332,8 @@ static int complete_request(git_http_client *client)
13261332{
13271333 int error = 0 ;
13281334
1329- assert (client && client -> state == SENDING_BODY );
1335+ GIT_ASSERT_ARG (client );
1336+ GIT_ASSERT (client -> state == SENDING_BODY );
13301337
13311338 if (client -> request_body_len && client -> request_body_remain ) {
13321339 git_error_set (GIT_ERROR_HTTP , "truncated write" );
@@ -1346,7 +1353,8 @@ int git_http_client_read_response(
13461353 http_parser_context parser_context = {0 };
13471354 int error ;
13481355
1349- assert (response && client );
1356+ GIT_ASSERT_ARG (response );
1357+ GIT_ASSERT_ARG (client );
13501358
13511359 if (client -> state == SENDING_BODY ) {
13521360 if ((error = complete_request (client )) < 0 )
@@ -1386,7 +1394,7 @@ int git_http_client_read_response(
13861394 goto done ;
13871395 }
13881396
1389- assert (client -> state == READING_BODY || client -> state == DONE );
1397+ GIT_ASSERT (client -> state == READING_BODY || client -> state == DONE );
13901398
13911399done :
13921400 git_buf_dispose (& parser_context .parse_header_name );
@@ -1439,7 +1447,7 @@ int git_http_client_read_body(
14391447 break ;
14401448 }
14411449
1442- assert (parser_context .output_written <= INT_MAX );
1450+ GIT_ASSERT (parser_context .output_written <= INT_MAX );
14431451 error = (int )parser_context .output_written ;
14441452
14451453done :
@@ -1493,7 +1501,7 @@ int git_http_client_new(
14931501{
14941502 git_http_client * client ;
14951503
1496- assert (out );
1504+ GIT_ASSERT_ARG (out );
14971505
14981506 client = git__calloc (1 , sizeof (git_http_client ));
14991507 GIT_ERROR_CHECK_ALLOC (client );
0 commit comments