diff options
Diffstat (limited to 'src/json/json_gnsrecord.c')
-rw-r--r-- | src/json/json_gnsrecord.c | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/src/json/json_gnsrecord.c b/src/json/json_gnsrecord.c index eef9e0e79..2ba4da591 100644 --- a/src/json/json_gnsrecord.c +++ b/src/json/json_gnsrecord.c | |||
@@ -48,24 +48,19 @@ struct GnsRecordInfo | |||
48 | static void | 48 | static void |
49 | cleanup_recordinfo (struct GnsRecordInfo *gnsrecord_info) | 49 | cleanup_recordinfo (struct GnsRecordInfo *gnsrecord_info) |
50 | { | 50 | { |
51 | if (NULL != gnsrecord_info) | 51 | if (NULL != *(gnsrecord_info->rd)) |
52 | { | 52 | { |
53 | if (NULL != *(gnsrecord_info->rd)) | 53 | for (int i = 0; i < *(gnsrecord_info->rd_count); i++) |
54 | { | 54 | { |
55 | for (int i = 0; i < *(gnsrecord_info->rd_count); i++) | 55 | if (NULL != (*(gnsrecord_info->rd))[i].data) |
56 | { | 56 | GNUNET_free ((char *) (*(gnsrecord_info->rd))[i].data); |
57 | if (NULL != (*(gnsrecord_info->rd))[i].data) | ||
58 | GNUNET_free ((char *) (*(gnsrecord_info->rd))[i].data); | ||
59 | } | ||
60 | GNUNET_free (*(gnsrecord_info->rd)); | ||
61 | *(gnsrecord_info->rd) = NULL; | ||
62 | } | 57 | } |
63 | if (NULL != *(gnsrecord_info->name)) | 58 | GNUNET_free (*(gnsrecord_info->rd)); |
64 | GNUNET_free (*(gnsrecord_info->name)); | 59 | *(gnsrecord_info->rd) = NULL; |
65 | *(gnsrecord_info->name) = NULL; | ||
66 | GNUNET_free (gnsrecord_info); | ||
67 | } | 60 | } |
68 | 61 | if (NULL != *(gnsrecord_info->name)) | |
62 | GNUNET_free (*(gnsrecord_info->name)); | ||
63 | *(gnsrecord_info->name) = NULL; | ||
69 | } | 64 | } |
70 | 65 | ||
71 | 66 | ||
@@ -210,7 +205,12 @@ parse_gnsrecordobject (void *cls, | |||
210 | } | 205 | } |
211 | gnsrecord_info = (struct GnsRecordInfo *) spec->ptr; | 206 | gnsrecord_info = (struct GnsRecordInfo *) spec->ptr; |
212 | *(gnsrecord_info->name) = GNUNET_strdup (name); | 207 | *(gnsrecord_info->name) = GNUNET_strdup (name); |
213 | return parse_record_data (gnsrecord_info, data); | 208 | if (GNUNET_OK != parse_record_data (gnsrecord_info, data)) |
209 | { | ||
210 | cleanup_recordinfo (gnsrecord_info); | ||
211 | return GNUNET_SYSERR; | ||
212 | } | ||
213 | return GNUNET_OK; | ||
214 | } | 214 | } |
215 | 215 | ||
216 | 216 | ||
@@ -224,7 +224,7 @@ static void | |||
224 | clean_gnsrecordobject (void *cls, struct GNUNET_JSON_Specification *spec) | 224 | clean_gnsrecordobject (void *cls, struct GNUNET_JSON_Specification *spec) |
225 | { | 225 | { |
226 | struct GnsRecordInfo *gnsrecord_info = (struct GnsRecordInfo *) spec->ptr; | 226 | struct GnsRecordInfo *gnsrecord_info = (struct GnsRecordInfo *) spec->ptr; |
227 | cleanup_recordinfo (gnsrecord_info); | 227 | GNUNET_free (gnsrecord_info); |
228 | } | 228 | } |
229 | 229 | ||
230 | 230 | ||
@@ -244,12 +244,12 @@ GNUNET_JSON_spec_gnsrecord (struct GNUNET_GNSRECORD_Data **rd, | |||
244 | gnsrecord_info->name = name; | 244 | gnsrecord_info->name = name; |
245 | gnsrecord_info->rd_count = rd_count; | 245 | gnsrecord_info->rd_count = rd_count; |
246 | struct GNUNET_JSON_Specification ret = {.parser = &parse_gnsrecordobject, | 246 | struct GNUNET_JSON_Specification ret = {.parser = &parse_gnsrecordobject, |
247 | .cleaner = &clean_gnsrecordobject, | 247 | .cleaner = &clean_gnsrecordobject, |
248 | .cls = NULL, | 248 | .cls = NULL, |
249 | .field = NULL, | 249 | .field = NULL, |
250 | .ptr = (struct GnsRecordInfo *) | 250 | .ptr = (struct GnsRecordInfo *) |
251 | gnsrecord_info, | 251 | gnsrecord_info, |
252 | .ptr_size = 0, | 252 | .ptr_size = 0, |
253 | .size_ptr = NULL}; | 253 | .size_ptr = NULL}; |
254 | return ret; | 254 | return ret; |
255 | } | 255 | } |