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.

stephan 2011-10-19 15:47 json-multitag-test
Commit 2f48be58a72d55ff8b390044546ea3d9b22cb218
1 file changed +4 -2
+4 -2
--- src/json.c
+++ src/json.c
@@ -1462,12 +1462,12 @@
14621462
**
14631463
** If payload is not NULL and resultCode is 0 then it is set as the
14641464
** "payload" property of the returned object. If resultCode is
14651465
** non-zero and payload is not NULL then this function calls
14661466
** 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.
14691469
**
14701470
** pMsg is an optional message string property (resultText) of the
14711471
** response. If resultCode is non-0 and pMsg is NULL then
14721472
** json_err_cstr() is used to get the error string. The caller may
14731473
** provide his own or may use an empty string to suppress the
@@ -2396,10 +2396,11 @@
23962396
rc = 0;
23972397
g.json.dispatchDepth = 1;
23982398
payload = (*pageDef->func)();
23992399
}
24002400
if( g.json.resultCode ){
2401
+ cson_value_free(payload);
24012402
json_err(g.json.resultCode, NULL, 0);
24022403
}else{
24032404
cson_value * root = json_create_response(rc, NULL, payload);
24042405
json_send_response(root);
24052406
cson_value_free(root);
@@ -2484,10 +2485,11 @@
24842485
rc = 0;
24852486
g.json.dispatchDepth = 1;
24862487
payload = (*pageDef->func)();
24872488
}
24882489
if( g.json.resultCode ){
2490
+ cson_value_free(payload);
24892491
json_err(g.json.resultCode, NULL, 1);
24902492
}else{
24912493
payload = json_create_response(rc, NULL, payload);
24922494
json_send_response(payload);
24932495
cson_value_free( payload );
24942496
--- 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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button