@@ -351,11 +351,12 @@ int json_process_chunk(modsec_rec *msr, const char *buf, unsigned int size, char
351
351
/* Feed our parser and catch any errors */
352
352
msr -> json -> status = yajl_parse (msr -> json -> handle , buf , size );
353
353
if (msr -> json -> status != yajl_status_ok ) {
354
- /* We need to free the yajl error message later, how to do this? */
355
354
if (msr -> json -> depth_limit_exceeded ) {
356
355
* error_msg = "JSON depth limit exceeded" ;
357
356
} 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 );
359
360
}
360
361
return -1 ;
361
362
}
@@ -375,11 +376,12 @@ int json_complete(modsec_rec *msr, char **error_msg) {
375
376
/* Wrap up the parsing process */
376
377
msr -> json -> status = yajl_complete_parse (msr -> json -> handle );
377
378
if (msr -> json -> status != yajl_status_ok ) {
378
- /* We need to free the yajl error message later, how to do this? */
379
379
if (msr -> json -> depth_limit_exceeded ) {
380
380
* error_msg = "JSON depth limit exceeded" ;
381
381
} 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 );
383
385
}
384
386
385
387
return -1 ;
0 commit comments