summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@gnutls.org>2017-09-23 11:11:27 +0200
committerNikos Mavrogiannopoulos <nmav@gnutls.org>2017-09-24 10:29:53 +0000
commit0104649760d442a95d350b30922f02dec4081ba7 (patch)
tree73e663e3de14994d343f58794dabebde53c38e22 /src
parentf6ee63173f892cb324bffb4da173334a1c2fe8d0 (diff)
downloadgnutls-0104649760d442a95d350b30922f02dec4081ba7.tar.gz
ocsptool: eliminate memory leaks
Signed-off-by: Nikos Mavrogiannopoulos <nmav@gnutls.org>
Diffstat (limited to 'src')
-rw-r--r--src/ocsptool-common.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/ocsptool-common.c b/src/ocsptool-common.c
index fdbd662c31..a2d971b4b0 100644
--- a/src/ocsptool-common.c
+++ b/src/ocsptool-common.c
@@ -219,7 +219,8 @@ int send_ocsp_request(const char *server,
if (ret < 0 || ud.size == 0) {
perror("recv");
- return -1;
+ ret = -1;
+ goto cleanup;
}
socket_bye(&hd, 0);
@@ -227,22 +228,29 @@ int send_ocsp_request(const char *server,
p = memmem(ud.data, ud.size, "\r\n\r\n", 4);
if (p == NULL) {
fprintf(stderr, "Cannot interpret HTTP response\n");
- return -1;
+ ret = -1;
+ goto cleanup;
}
p += 4;
resp_data->size = ud.size - (p - ud.data);
resp_data->data = malloc(resp_data->size);
- if (resp_data->data == NULL)
- return -1;
+ if (resp_data->data == NULL) {
+ perror("recv");
+ ret = -1;
+ goto cleanup;
+ }
memcpy(resp_data->data, p, resp_data->size);
+ ret = 0;
+
+ cleanup:
free(ud.data);
if (url != server)
free(url);
- return 0;
+ return ret;
}
void print_ocsp_verify_res(unsigned int output)