]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-http: free resources used in the tests
authorPhil Carmody <phil@dovecot.fi>
Mon, 16 Nov 2015 10:26:32 +0000 (12:26 +0200)
committerPhil Carmody <phil@dovecot.fi>
Mon, 16 Nov 2015 10:26:32 +0000 (12:26 +0200)
Signed-off-by: Phil Carmody <phil@dovecot.fi>
src/lib-http/test-http-header-parser.c
src/lib-http/test-http-request-parser.c
src/lib-http/test-http-response-parser.c
src/lib-http/test-http-transfer.c

index dfec4805431f6234d1365fd6a26d65ce17f8ec75..de8370be2efee974f4c2e74b638bdabdb82dd690 100644 (file)
@@ -232,6 +232,7 @@ static void test_http_header_parse_valid(void)
 
                test_out_reason("parse success", ret > 0, error);
                test_end();
+               i_stream_unref(&input);
                http_header_parser_deinit(&parser);
        } T_END;
 }
@@ -359,6 +360,7 @@ static void test_http_header_parse_invalid(void)
 
                test_out_reason("parse failure", ret < 0, error);
                test_end();
+               i_stream_unref(&input);
                http_header_parser_deinit(&parser);
        } T_END;
 }
index 4c5eeb0783a64dd780627c324f771e5794c13e90..4a2fc0e3fc8a7801f76271518fa0bc68cabdb36f 100644 (file)
@@ -188,6 +188,8 @@ static void test_http_request_parse_valid(void)
                                (parser, NULL, &request, &error_code, &error);
                }
                test_istream_set_size(input, request_text_len);
+               i_stream_unref(&input);
+
                while (ret > 0) {
                        if (request.payload != NULL) {
                                buffer_set_used_size(payload_buffer, 0);
@@ -402,6 +404,7 @@ static void test_http_request_parse_invalid(void)
                request_text = test->request;
                input = i_stream_create_from_data(request_text, strlen(request_text));
                parser = http_request_parser_init(input, NULL);
+               i_stream_unref(&input);
 
                test_begin(t_strdup_printf("http request invalid [%d]", i));
 
@@ -423,9 +426,12 @@ static void test_http_request_parse_invalid(void)
        input = i_stream_create_from_data(invalid_request_with_nuls,
                                          sizeof(invalid_request_with_nuls)-1);
        parser = http_request_parser_init(input, NULL);
+       i_stream_unref(&input);
+
        while ((ret=http_request_parse_next
                (parser, NULL, &request, &error_code, &error)) > 0);
        test_assert(ret < 0);
+       http_request_parser_deinit(&parser);
        test_end();
 }
 
index 04572cdef8b95f963b7616e5547662fcd886ed9c..2890adbe946fb8a1e0ec1aa9cd7dd5b8e10bc9ec 100644 (file)
@@ -119,6 +119,8 @@ static void test_http_response_parse_valid(void)
                        ret = http_response_parse_next(parser, FALSE, &response, &error);
                }
                test_istream_set_size(input, response_text_len);
+               i_stream_unref(&input);
+
                while (ret > 0) {
                        if (response.payload != NULL) {
                                buffer_set_used_size(payload_buffer, 0);
@@ -197,6 +199,7 @@ static void test_http_response_parse_invalid(void)
                response_text = test;
                input = i_stream_create_from_data(response_text, strlen(response_text));
                parser = http_response_parser_init(input, NULL);
+               i_stream_unref(&input);
 
                test_begin(t_strdup_printf("http response invalid [%d]", i));
 
@@ -231,6 +234,7 @@ static void test_http_response_parse_bad(void)
        input = i_stream_create_from_data(bad_response_with_nuls,
                                          sizeof(bad_response_with_nuls)-1);
        parser = http_response_parser_init(input, NULL);
+       i_stream_unref(&input);
        while ((ret=http_response_parse_next(parser, FALSE, &response, &error)) > 0);
        test_out("parse success", ret == 0);
        header = http_response_header_get(&response, "server");
@@ -240,6 +244,7 @@ static void test_http_response_parse_bad(void)
                        strcmp(header, "textserver") == 0);
        }
        test_end();
+       http_response_parser_deinit(&parser);
 }
 
 int main(void)
index 6febd2e90dfc959c3336011da603ce4eec16f82e..574e5d7d26c06313fb4d01c05be5e03da02bcb61 100644 (file)
@@ -100,12 +100,14 @@ static void test_http_transfer_chunked_input_valid(void)
 
                input = i_stream_create_from_data(in, strlen(in));
                chunked = http_transfer_chunked_istream_create(input, 0);
+               i_stream_unref(&input);
 
                buffer_set_used_size(payload_buffer, 0);
                output = o_stream_create_buffer(payload_buffer);
                test_out("payload read", o_stream_send_istream(output, chunked) > 0
                        && chunked->stream_errno == 0);
                o_stream_destroy(&output);
+               i_stream_unref(&chunked);
                stream_out = str_c(payload_buffer);
 
                test_out(t_strdup_printf("response->payload = %s",
@@ -194,11 +196,13 @@ static void test_http_transfer_chunked_input_invalid(void)
 
                input = i_stream_create_from_data(in, strlen(in));
                chunked = http_transfer_chunked_istream_create(input, 0);
+               i_stream_unref(&input);
 
                buffer_set_used_size(payload_buffer, 0);
                output = o_stream_create_buffer(payload_buffer);
                (void)o_stream_send_istream(output, chunked);
                test_out("payload read failure", chunked->stream_errno != 0);
+               i_stream_unref(&chunked);
                o_stream_destroy(&output);
 
                test_end();