Rearrange the error handling a bit in send_request(). The old code
authorscottmk <scottmk@9efc2488-bf62-4759-914b-345cdb29e865>
Mon, 1 Feb 2010 04:32:48 +0000 (04:32 +0000)
committerscottmk <scottmk@9efc2488-bf62-4759-914b-345cdb29e865>
Mon, 1 Feb 2010 04:32:48 +0000 (04:32 +0000)
looked like it would segfault in the case of a relay command.

M    src/srfsh/srfsh.c

git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@1913 9efc2488-bf62-4759-914b-345cdb29e865

src/srfsh/srfsh.c

index 1d394e9..dc1c733 100644 (file)
@@ -752,6 +752,10 @@ int send_request( const char* server,
                        osrfLogToStderr();
                        params = jsonParse( OSRF_BUFFER_C_STR( buffer ) );
                        osrfRestoreLogType();
                        osrfLogToStderr();
                        params = jsonParse( OSRF_BUFFER_C_STR( buffer ) );
                        osrfRestoreLogType();
+                       if( params == NULL) {
+                               fprintf(stderr, "JSON error detected, not executing\n");
+                               return 1;
+                       }
                }
        } else {
                if(!last_result || ! last_result->_result_content) { 
                }
        } else {
                if(!last_result || ! last_result->_result_content) { 
@@ -764,12 +768,6 @@ int send_request( const char* server,
                }
        }
 
                }
        }
 
-       if(buffer->n_used > 0 && params == NULL) {
-               fprintf(stderr, "JSON error detected, not executing\n");
-               jsonObjectFree(params);
-               return 1;
-       }
-
        int session_is_temporary;    // boolean
        osrfAppSession* session = osrfHashGet( server_hash, server );
        if( session ) {
        int session_is_temporary;    // boolean
        osrfAppSession* session = osrfHashGet( server_hash, server );
        if( session ) {