aboutsummaryrefslogtreecommitdiff
path: root/src/lib/util/strings.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/util/strings.c')
-rw-r--r--src/lib/util/strings.c14
1 files changed, 4 insertions, 10 deletions
diff --git a/src/lib/util/strings.c b/src/lib/util/strings.c
index e0ae6a2fa..f2b88ef47 100644
--- a/src/lib/util/strings.c
+++ b/src/lib/util/strings.c
@@ -1151,25 +1151,21 @@ GNUNET_STRINGS_parse_socket_addr (const char *addr,
1151 uint8_t *af, 1151 uint8_t *af,
1152 struct sockaddr **sa) 1152 struct sockaddr **sa)
1153{ 1153{
1154 char *cp = GNUNET_strdup (addr);
1155
1156 *af = AF_UNSPEC; 1154 *af = AF_UNSPEC;
1157 if ('[' == *addr) 1155 if ('[' == *addr)
1158 { 1156 {
1159 /* IPv6 */ 1157 /* IPv6 */
1160 *sa = GNUNET_malloc (sizeof(struct sockaddr_in6)); 1158 *sa = GNUNET_malloc (sizeof(struct sockaddr_in6));
1161 if (GNUNET_OK != 1159 if (GNUNET_OK !=
1162 GNUNET_STRINGS_to_address_ipv6 (cp, 1160 GNUNET_STRINGS_to_address_ipv6 (addr,
1163 strlen (cp), 1161 strlen (addr),
1164 (struct sockaddr_in6 *) *sa)) 1162 (struct sockaddr_in6 *) *sa))
1165 { 1163 {
1166 GNUNET_free (*sa); 1164 GNUNET_free (*sa);
1167 *sa = NULL; 1165 *sa = NULL;
1168 GNUNET_free (cp);
1169 return 0; 1166 return 0;
1170 } 1167 }
1171 *af = AF_INET6; 1168 *af = AF_INET6;
1172 GNUNET_free (cp);
1173 return sizeof(struct sockaddr_in6); 1169 return sizeof(struct sockaddr_in6);
1174 } 1170 }
1175 else 1171 else
@@ -1177,17 +1173,15 @@ GNUNET_STRINGS_parse_socket_addr (const char *addr,
1177 /* IPv4 */ 1173 /* IPv4 */
1178 *sa = GNUNET_malloc (sizeof(struct sockaddr_in)); 1174 *sa = GNUNET_malloc (sizeof(struct sockaddr_in));
1179 if (GNUNET_OK != 1175 if (GNUNET_OK !=
1180 GNUNET_STRINGS_to_address_ipv4 (cp, 1176 GNUNET_STRINGS_to_address_ipv4 (addr,
1181 strlen (cp), 1177 strlen (addr),
1182 (struct sockaddr_in *) *sa)) 1178 (struct sockaddr_in *) *sa))
1183 { 1179 {
1184 GNUNET_free (*sa); 1180 GNUNET_free (*sa);
1185 *sa = NULL; 1181 *sa = NULL;
1186 GNUNET_free (cp);
1187 return 0; 1182 return 0;
1188 } 1183 }
1189 *af = AF_INET; 1184 *af = AF_INET;
1190 GNUNET_free (cp);
1191 return sizeof(struct sockaddr_in); 1185 return sizeof(struct sockaddr_in);
1192 } 1186 }
1193} 1187}