Fossil SCM
fixed json_page_top() and json_cmd_top() to behave as documented when a callback returns non-NULL but does set the error state.
Commit
2f48be58a72d55ff8b390044546ea3d9b22cb218
Parent
1615544773bd6cd…
1 file changed
+4
-2
+4
-2
| --- src/json.c | ||
| +++ src/json.c | ||
| @@ -1462,12 +1462,12 @@ | ||
| 1462 | 1462 | ** |
| 1463 | 1463 | ** If payload is not NULL and resultCode is 0 then it is set as the |
| 1464 | 1464 | ** "payload" property of the returned object. If resultCode is |
| 1465 | 1465 | ** non-zero and payload is not NULL then this function calls |
| 1466 | 1466 | ** cson_value_free(payload) and does not insert the payload into the |
| 1467 | -** response. In either case, onwership of payload is transfered to | |
| 1468 | -** this function. | |
| 1467 | +** response. In either case, onwership of payload is transfered to (or | |
| 1468 | +** shared with, if the caller holds a reference) this function. | |
| 1469 | 1469 | ** |
| 1470 | 1470 | ** pMsg is an optional message string property (resultText) of the |
| 1471 | 1471 | ** response. If resultCode is non-0 and pMsg is NULL then |
| 1472 | 1472 | ** json_err_cstr() is used to get the error string. The caller may |
| 1473 | 1473 | ** provide his own or may use an empty string to suppress the |
| @@ -2396,10 +2396,11 @@ | ||
| 2396 | 2396 | rc = 0; |
| 2397 | 2397 | g.json.dispatchDepth = 1; |
| 2398 | 2398 | payload = (*pageDef->func)(); |
| 2399 | 2399 | } |
| 2400 | 2400 | if( g.json.resultCode ){ |
| 2401 | + cson_value_free(payload); | |
| 2401 | 2402 | json_err(g.json.resultCode, NULL, 0); |
| 2402 | 2403 | }else{ |
| 2403 | 2404 | cson_value * root = json_create_response(rc, NULL, payload); |
| 2404 | 2405 | json_send_response(root); |
| 2405 | 2406 | cson_value_free(root); |
| @@ -2484,10 +2485,11 @@ | ||
| 2484 | 2485 | rc = 0; |
| 2485 | 2486 | g.json.dispatchDepth = 1; |
| 2486 | 2487 | payload = (*pageDef->func)(); |
| 2487 | 2488 | } |
| 2488 | 2489 | if( g.json.resultCode ){ |
| 2490 | + cson_value_free(payload); | |
| 2489 | 2491 | json_err(g.json.resultCode, NULL, 1); |
| 2490 | 2492 | }else{ |
| 2491 | 2493 | payload = json_create_response(rc, NULL, payload); |
| 2492 | 2494 | json_send_response(payload); |
| 2493 | 2495 | cson_value_free( payload ); |
| 2494 | 2496 |
| --- src/json.c | |
| +++ src/json.c | |
| @@ -1462,12 +1462,12 @@ | |
| 1462 | ** |
| 1463 | ** If payload is not NULL and resultCode is 0 then it is set as the |
| 1464 | ** "payload" property of the returned object. If resultCode is |
| 1465 | ** non-zero and payload is not NULL then this function calls |
| 1466 | ** cson_value_free(payload) and does not insert the payload into the |
| 1467 | ** response. In either case, onwership of payload is transfered to |
| 1468 | ** this function. |
| 1469 | ** |
| 1470 | ** pMsg is an optional message string property (resultText) of the |
| 1471 | ** response. If resultCode is non-0 and pMsg is NULL then |
| 1472 | ** json_err_cstr() is used to get the error string. The caller may |
| 1473 | ** provide his own or may use an empty string to suppress the |
| @@ -2396,10 +2396,11 @@ | |
| 2396 | rc = 0; |
| 2397 | g.json.dispatchDepth = 1; |
| 2398 | payload = (*pageDef->func)(); |
| 2399 | } |
| 2400 | if( g.json.resultCode ){ |
| 2401 | json_err(g.json.resultCode, NULL, 0); |
| 2402 | }else{ |
| 2403 | cson_value * root = json_create_response(rc, NULL, payload); |
| 2404 | json_send_response(root); |
| 2405 | cson_value_free(root); |
| @@ -2484,10 +2485,11 @@ | |
| 2484 | rc = 0; |
| 2485 | g.json.dispatchDepth = 1; |
| 2486 | payload = (*pageDef->func)(); |
| 2487 | } |
| 2488 | if( g.json.resultCode ){ |
| 2489 | json_err(g.json.resultCode, NULL, 1); |
| 2490 | }else{ |
| 2491 | payload = json_create_response(rc, NULL, payload); |
| 2492 | json_send_response(payload); |
| 2493 | cson_value_free( payload ); |
| 2494 |
| --- src/json.c | |
| +++ src/json.c | |
| @@ -1462,12 +1462,12 @@ | |
| 1462 | ** |
| 1463 | ** If payload is not NULL and resultCode is 0 then it is set as the |
| 1464 | ** "payload" property of the returned object. If resultCode is |
| 1465 | ** non-zero and payload is not NULL then this function calls |
| 1466 | ** cson_value_free(payload) and does not insert the payload into the |
| 1467 | ** response. In either case, onwership of payload is transfered to (or |
| 1468 | ** shared with, if the caller holds a reference) this function. |
| 1469 | ** |
| 1470 | ** pMsg is an optional message string property (resultText) of the |
| 1471 | ** response. If resultCode is non-0 and pMsg is NULL then |
| 1472 | ** json_err_cstr() is used to get the error string. The caller may |
| 1473 | ** provide his own or may use an empty string to suppress the |
| @@ -2396,10 +2396,11 @@ | |
| 2396 | rc = 0; |
| 2397 | g.json.dispatchDepth = 1; |
| 2398 | payload = (*pageDef->func)(); |
| 2399 | } |
| 2400 | if( g.json.resultCode ){ |
| 2401 | cson_value_free(payload); |
| 2402 | json_err(g.json.resultCode, NULL, 0); |
| 2403 | }else{ |
| 2404 | cson_value * root = json_create_response(rc, NULL, payload); |
| 2405 | json_send_response(root); |
| 2406 | cson_value_free(root); |
| @@ -2484,10 +2485,11 @@ | |
| 2485 | rc = 0; |
| 2486 | g.json.dispatchDepth = 1; |
| 2487 | payload = (*pageDef->func)(); |
| 2488 | } |
| 2489 | if( g.json.resultCode ){ |
| 2490 | cson_value_free(payload); |
| 2491 | json_err(g.json.resultCode, NULL, 1); |
| 2492 | }else{ |
| 2493 | payload = json_create_response(rc, NULL, payload); |
| 2494 | json_send_response(payload); |
| 2495 | cson_value_free( payload ); |
| 2496 |