dovecot-2.2: lib-http: free resources used in the tests
dovecot at dovecot.org
dovecot at dovecot.org
Mon Nov 16 10:30:22 UTC 2015
details: http://hg.dovecot.org/dovecot-2.2/rev/f049fe9e7799
changeset: 19360:f049fe9e7799
user: Phil Carmody <phil at dovecot.fi>
date: Mon Nov 16 12:26:32 2015 +0200
description:
lib-http: free resources used in the tests
Signed-off-by: Phil Carmody <phil at dovecot.fi>
diffstat:
src/lib-http/test-http-header-parser.c | 2 ++
src/lib-http/test-http-request-parser.c | 6 ++++++
src/lib-http/test-http-response-parser.c | 5 +++++
src/lib-http/test-http-transfer.c | 4 ++++
4 files changed, 17 insertions(+), 0 deletions(-)
diffs (120 lines):
diff -r fe23c9b18c9d -r f049fe9e7799 src/lib-http/test-http-header-parser.c
--- a/src/lib-http/test-http-header-parser.c Mon Nov 16 12:26:06 2015 +0200
+++ b/src/lib-http/test-http-header-parser.c Mon Nov 16 12:26:32 2015 +0200
@@ -232,6 +232,7 @@
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 @@
test_out_reason("parse failure", ret < 0, error);
test_end();
+ i_stream_unref(&input);
http_header_parser_deinit(&parser);
} T_END;
}
diff -r fe23c9b18c9d -r f049fe9e7799 src/lib-http/test-http-request-parser.c
--- a/src/lib-http/test-http-request-parser.c Mon Nov 16 12:26:06 2015 +0200
+++ b/src/lib-http/test-http-request-parser.c Mon Nov 16 12:26:32 2015 +0200
@@ -188,6 +188,8 @@
(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 @@
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 @@
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();
}
diff -r fe23c9b18c9d -r f049fe9e7799 src/lib-http/test-http-response-parser.c
--- a/src/lib-http/test-http-response-parser.c Mon Nov 16 12:26:06 2015 +0200
+++ b/src/lib-http/test-http-response-parser.c Mon Nov 16 12:26:32 2015 +0200
@@ -119,6 +119,8 @@
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 @@
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 @@
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 @@
strcmp(header, "textserver") == 0);
}
test_end();
+ http_response_parser_deinit(&parser);
}
int main(void)
diff -r fe23c9b18c9d -r f049fe9e7799 src/lib-http/test-http-transfer.c
--- a/src/lib-http/test-http-transfer.c Mon Nov 16 12:26:06 2015 +0200
+++ b/src/lib-http/test-http-transfer.c Mon Nov 16 12:26:32 2015 +0200
@@ -100,12 +100,14 @@
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 @@
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();
More information about the dovecot-cvs
mailing list