diff options
-rw-r--r-- | src/ping903.c | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/src/ping903.c b/src/ping903.c index 06597bb..df1196b 100644 --- a/src/ping903.c +++ b/src/ping903.c | |||
@@ -293,25 +293,21 @@ http_response_detail(struct MHD_Connection *conn, | |||
293 | char const *method, char const *url, int status, | 293 | char const *method, char const *url, int status, |
294 | char const *message, int index) | 294 | char const *message, int index) |
295 | { | 295 | { |
296 | struct json_value *jv, *errobj = json_new_object(); | 296 | struct json_value *jv = NULL, *errobj = json_new_object(); |
297 | int rc; | ||
298 | 297 | ||
299 | if (!errobj) | 298 | if (!errobj) |
300 | goto err; | 299 | goto err; |
301 | if ((jv = json_new_string(message)) == NULL) | 300 | if ((jv = json_new_string(message)) == NULL |
302 | goto err; | 301 | || json_object_set(errobj, "message", jv)) |
303 | if (json_object_set(errobj, "message", jv)) | ||
304 | goto err; | 302 | goto err; |
305 | if (index) { | 303 | if (index) { |
306 | if ((jv = json_new_number(index)) == NULL) | 304 | if ((jv = json_new_number(index)) == NULL |
307 | goto err; | 305 | || json_object_set(errobj, "index", jv)) |
308 | if (json_object_set(errobj, "index", jv)) | ||
309 | goto err; | 306 | goto err; |
310 | } | 307 | } |
311 | rc = httpd_json_response(conn, url, method, status, errobj); | 308 | return httpd_json_response(conn, url, method, status, errobj); |
312 | json_value_free(errobj); | ||
313 | return rc; | ||
314 | err: | 309 | err: |
310 | json_value_free(jv); | ||
315 | json_value_free(errobj); | 311 | json_value_free(errobj); |
316 | return http_response(conn, method, url, | 312 | return http_response(conn, method, url, |
317 | MHD_HTTP_INTERNAL_SERVER_ERROR); | 313 | MHD_HTTP_INTERNAL_SERVER_ERROR); |