diff options
Diffstat (limited to 'src/gnsrecord/gnsrecord_misc.c')
-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 | ||