diff options
author | Christian Grothoff <christian@grothoff.org> | 2018-01-04 22:42:55 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2018-01-04 22:42:55 +0100 |
commit | a90bc78b266ee8945b8e289e94f2f7503b18c3e1 (patch) | |
tree | e86a7b17233e9222292800e2e3e5c0c88220c120 /src/gns | |
parent | 23a95ded83313c8df50c5c34e0c12469e056545c (diff) | |
download | gnunet-a90bc78b266ee8945b8e289e94f2f7503b18c3e1.tar.gz gnunet-a90bc78b266ee8945b8e289e94f2f7503b18c3e1.zip |
avoid freeing uninit ptr on error path
Diffstat (limited to 'src/gns')
-rw-r--r-- | src/gns/gnunet-service-gns_resolver.c | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/src/gns/gnunet-service-gns_resolver.c b/src/gns/gnunet-service-gns_resolver.c index 54d7ff94b..e14a05d45 100644 --- a/src/gns/gnunet-service-gns_resolver.c +++ b/src/gns/gnunet-service-gns_resolver.c | |||
@@ -1019,6 +1019,7 @@ recursive_dns_resolution (struct GNS_ResolverHandle *rh) | |||
1019 | struct GNUNET_DNSPARSER_Packet *p; | 1019 | struct GNUNET_DNSPARSER_Packet *p; |
1020 | char *dns_request; | 1020 | char *dns_request; |
1021 | size_t dns_request_length; | 1021 | size_t dns_request_length; |
1022 | int ret; | ||
1022 | 1023 | ||
1023 | ac = rh->ac_tail; | 1024 | ac = rh->ac_tail; |
1024 | GNUNET_assert (NULL != ac); | 1025 | GNUNET_assert (NULL != ac); |
@@ -1051,11 +1052,16 @@ recursive_dns_resolution (struct GNS_ResolverHandle *rh) | |||
1051 | UINT16_MAX); | 1052 | UINT16_MAX); |
1052 | p->flags.opcode = GNUNET_TUN_DNS_OPCODE_QUERY; | 1053 | p->flags.opcode = GNUNET_TUN_DNS_OPCODE_QUERY; |
1053 | p->flags.recursion_desired = 1; | 1054 | p->flags.recursion_desired = 1; |
1054 | if (GNUNET_OK != | 1055 | ret = GNUNET_DNSPARSER_pack (p, |
1055 | GNUNET_DNSPARSER_pack (p, 1024, &dns_request, &dns_request_length)) | 1056 | 1024, |
1057 | &dns_request, | ||
1058 | &dns_request_length); | ||
1059 | if (GNUNET_OK != ret) | ||
1056 | { | 1060 | { |
1057 | GNUNET_break (0); | 1061 | GNUNET_break (0); |
1058 | rh->proc (rh->proc_cls, 0, NULL); | 1062 | rh->proc (rh->proc_cls, |
1063 | 0, | ||
1064 | NULL); | ||
1059 | GNS_resolver_lookup_cancel (rh); | 1065 | GNS_resolver_lookup_cancel (rh); |
1060 | } | 1066 | } |
1061 | else | 1067 | else |
@@ -1071,7 +1077,8 @@ recursive_dns_resolution (struct GNS_ResolverHandle *rh) | |||
1071 | &fail_resolution, | 1077 | &fail_resolution, |
1072 | rh); | 1078 | rh); |
1073 | } | 1079 | } |
1074 | GNUNET_free (dns_request); | 1080 | if (GNUNET_SYSERR != ret) |
1081 | GNUNET_free (dns_request); | ||
1075 | GNUNET_DNSPARSER_free_packet (p); | 1082 | GNUNET_DNSPARSER_free_packet (p); |
1076 | } | 1083 | } |
1077 | 1084 | ||
@@ -1462,10 +1469,10 @@ handle_gns_resolution_result (void *cls, | |||
1462 | vpn_ctx->rd_data = GNUNET_malloc (vpn_ctx->rd_data_size); | 1469 | vpn_ctx->rd_data = GNUNET_malloc (vpn_ctx->rd_data_size); |
1463 | vpn_ctx->rd_count = rd_count; | 1470 | vpn_ctx->rd_count = rd_count; |
1464 | GNUNET_assert (vpn_ctx->rd_data_size == | 1471 | GNUNET_assert (vpn_ctx->rd_data_size == |
1465 | GNUNET_GNSRECORD_records_serialize (rd_count, | 1472 | (size_t) GNUNET_GNSRECORD_records_serialize (rd_count, |
1466 | rd, | 1473 | rd, |
1467 | vpn_ctx->rd_data_size, | 1474 | vpn_ctx->rd_data_size, |
1468 | vpn_ctx->rd_data)); | 1475 | vpn_ctx->rd_data)); |
1469 | vpn_ctx->vpn_request = GNUNET_VPN_redirect_to_peer (vpn_handle, | 1476 | vpn_ctx->vpn_request = GNUNET_VPN_redirect_to_peer (vpn_handle, |
1470 | af, | 1477 | af, |
1471 | ntohs (vpn->proto), | 1478 | ntohs (vpn->proto), |