diff options
author | Martin Schanzenbach <mschanzenbach@posteo.de> | 2021-03-26 14:28:27 +0100 |
---|---|---|
committer | Martin Schanzenbach <mschanzenbach@posteo.de> | 2021-03-26 14:28:27 +0100 |
commit | fa8b5926395406f96654aa5a0b84848dc4e1a519 (patch) | |
tree | 784111c575f181b7eff616a7a5d8ff7a41ea4394 /src/gnsrecord | |
parent | 655fc47e417831125d6ebb5f68d4e86371cb931f (diff) | |
download | gnunet-fa8b5926395406f96654aa5a0b84848dc4e1a519.tar.gz gnunet-fa8b5926395406f96654aa5a0b84848dc4e1a519.zip |
-fixing memleaks and nptr derefs
Diffstat (limited to 'src/gnsrecord')
-rw-r--r-- | src/gnsrecord/gnsrecord_misc.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/gnsrecord/gnsrecord_misc.c b/src/gnsrecord/gnsrecord_misc.c index dacd7ca31..b907eed27 100644 --- a/src/gnsrecord/gnsrecord_misc.c +++ b/src/gnsrecord/gnsrecord_misc.c | |||
@@ -296,15 +296,20 @@ GNUNET_GNSRECORD_data_from_identity (const struct | |||
296 | size_t *data_size, | 296 | size_t *data_size, |
297 | uint32_t *type) | 297 | uint32_t *type) |
298 | { | 298 | { |
299 | char *tmp; | ||
299 | *type = ntohl (key->type); | 300 | *type = ntohl (key->type); |
300 | *data_size = GNUNET_IDENTITY_key_get_length (key); | 301 | *data_size = GNUNET_IDENTITY_key_get_length (key); |
301 | if (0 == *data_size) | 302 | if (0 == *data_size) |
302 | return GNUNET_SYSERR; | 303 | return GNUNET_SYSERR; |
303 | *data = GNUNET_malloc (*data_size); | 304 | tmp = GNUNET_malloc (*data_size); |
304 | return (GNUNET_IDENTITY_write_key_to_buffer (key, *data, *data_size) == | 305 | if (GNUNET_IDENTITY_write_key_to_buffer (key, tmp, *data_size) |
305 | *data_size? | 306 | != *data_size) { |
306 | GNUNET_OK : | 307 | GNUNET_free (tmp); |
307 | GNUNET_SYSERR); | 308 | *data_size = 0; |
309 | return GNUNET_SYSERR; | ||
310 | } | ||
311 | *data = tmp; | ||
312 | return GNUNET_OK; | ||
308 | } | 313 | } |
309 | 314 | ||
310 | 315 | ||