From 54ec02fedfa271e9a4a6cff83da535b9167e2d77 Mon Sep 17 00:00:00 2001 From: miker Date: Wed, 31 May 2006 17:25:53 +0000 Subject: [PATCH] attempting to fix the extra null in respondComplete git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@732 9efc2488-bf62-4759-914b-345cdb29e865 --- src/libstack/osrf_app_session.c | 23 ++++++++++++++--------- src/libstack/osrf_application.c | 4 +++- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/libstack/osrf_app_session.c b/src/libstack/osrf_app_session.c index b65c941..e9b88e1 100644 --- a/src/libstack/osrf_app_session.c +++ b/src/libstack/osrf_app_session.c @@ -618,20 +618,25 @@ int osrfAppRequestRespondComplete( osrf_message* payload = osrf_message_init( RESULT, requestId, 1 ); osrf_message_set_status_info( payload, NULL, "OK", OSRF_STATUS_OK ); - char* json = jsonObjectToJSON( data ); - osrf_message_set_result_content( payload, json ); - free(json); - osrf_message* status = osrf_message_init( STATUS, requestId, 1); osrf_message_set_status_info( status, "osrfConnectStatus", "Request Complete", OSRF_STATUS_COMPLETE ); + + if (data) { + char* json = jsonObjectToJSON( data ); + osrf_message_set_result_content( payload, json ); + free(json); - osrfMessage* ms[2]; - ms[0] = payload; - ms[1] = status; + osrfMessage* ms[2]; + ms[0] = payload; + ms[1] = status; - osrfAppSessionSendBatch( ses, ms, 2 ); + osrfAppSessionSendBatch( ses, ms, 2 ); + + osrf_message_free( payload ); + } else { + osrfAppSessionSendBatch( ses, &status, 1 ); + } - osrf_message_free( payload ); osrf_message_free( status ); /* join and free */ diff --git a/src/libstack/osrf_application.c b/src/libstack/osrf_application.c index d4b954e..cf49c12 100644 --- a/src/libstack/osrf_application.c +++ b/src/libstack/osrf_application.c @@ -275,7 +275,9 @@ int _osrfAppRespond( osrfMethodContext* ctx, jsonObject* data, int complete ) { if( ctx->responses == NULL ) ctx->responses = jsonParseString("[]"); - jsonObjectPush( ctx->responses, jsonObjectClone(data) ); + + if ( data != NULL ) + jsonObjectPush( ctx->responses, jsonObjectClone(data) ); } -- 2.11.0