@@ -351,11 +351,12 @@ int json_process_chunk(modsec_rec *msr, const char *buf, unsigned int size, char
351351 /* Feed our parser and catch any errors */
352352 msr -> json -> status = yajl_parse (msr -> json -> handle , buf , size );
353353 if (msr -> json -> status != yajl_status_ok ) {
354- /* We need to free the yajl error message later, how to do this? */
355354 if (msr -> json -> depth_limit_exceeded ) {
356355 * error_msg = "JSON depth limit exceeded" ;
357356 } else {
358- * error_msg = yajl_get_error (msr -> json -> handle , 0 , NULL , 0 );
357+ char * yajl_err = yajl_get_error (msr -> json -> handle , 0 , buf , size );
358+ * error_msg = apr_pstrdup (msr -> mp , yajl_err );
359+ yajl_free_error (msr -> json -> handle , yajl_err );
359360 }
360361 return -1 ;
361362 }
@@ -375,11 +376,12 @@ int json_complete(modsec_rec *msr, char **error_msg) {
375376 /* Wrap up the parsing process */
376377 msr -> json -> status = yajl_complete_parse (msr -> json -> handle );
377378 if (msr -> json -> status != yajl_status_ok ) {
378- /* We need to free the yajl error message later, how to do this? */
379379 if (msr -> json -> depth_limit_exceeded ) {
380380 * error_msg = "JSON depth limit exceeded" ;
381381 } else {
382- * error_msg = yajl_get_error (msr -> json -> handle , 0 , NULL , 0 );
382+ char * yajl_err = yajl_get_error (msr -> json -> handle , 0 , NULL , 0 );
383+ * error_msg = apr_pstrdup (msr -> mp , yajl_err );
384+ yajl_free_error (msr -> json -> handle , yajl_err );
383385 }
384386
385387 return -1 ;
0 commit comments