summaryrefslogtreecommitdiffstats
path: root/plugins/mmjsonparse/mmjsonparse.c
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2013-01-30 15:48:18 +0100
committerRainer Gerhards <rgerhards@adiscon.com>2013-01-30 15:48:18 +0100
commite082cb074293bf2df5fd13fb79845dc7e44298b8 (patch)
tree4b602111c5d8fc2914a8c7332370d91608e8d51b /plugins/mmjsonparse/mmjsonparse.c
parentf53d30f89cd5d0b0c0898a5e9823fc0bcfa89625 (diff)
downloadrsyslog-e082cb074293bf2df5fd13fb79845dc7e44298b8.tar.gz
rsyslog-e082cb074293bf2df5fd13fb79845dc7e44298b8.tar.bz2
rsyslog-e082cb074293bf2df5fd13fb79845dc7e44298b8.zip
bugfix: mmjsonparse segfault if new-style config was used
Diffstat (limited to 'plugins/mmjsonparse/mmjsonparse.c')
-rw-r--r--plugins/mmjsonparse/mmjsonparse.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/plugins/mmjsonparse/mmjsonparse.c b/plugins/mmjsonparse/mmjsonparse.c
index ce32b7b7..c47aceb6 100644
--- a/plugins/mmjsonparse/mmjsonparse.c
+++ b/plugins/mmjsonparse/mmjsonparse.c
@@ -95,6 +95,13 @@ ENDfreeCnf
BEGINcreateInstance
CODESTARTcreateInstance
+ pData->tokener = json_tokener_new();
+ if(pData->tokener == NULL) {
+ errmsg.LogError(0, RS_RET_ERR, "error: could not create json "
+ "tokener, cannot activate action");
+ ABORT_FINALIZE(RS_RET_ERR);
+ }
+finalize_it:
ENDcreateInstance
@@ -112,7 +119,7 @@ ENDfreeInstance
BEGINdbgPrintInstInfo
CODESTARTdbgPrintInstInfo
- dbgprintf("mmjsonparse\n");
+ DBGPRINTF("mmjsonparse\n");
ENDdbgPrintInstInfo
@@ -128,7 +135,8 @@ processJSON(instanceData *pData, msg_t *pMsg, char *buf, size_t lenBuf)
const char *errMsg;
DEFiRet;
- dbgprintf("mmjsonparse: toParse: '%s'\n", buf);
+ assert(pData->tokener != NULL);
+ DBGPRINTF("mmjsonparse: toParse: '%s'\n", buf);
json_tokener_reset(pData->tokener);
json = json_tokener_parse_ex(pData->tokener, buf, lenBuf);
@@ -147,7 +155,7 @@ processJSON(instanceData *pData, msg_t *pMsg, char *buf, size_t lenBuf)
else if(!json_object_is_type(json, json_type_object))
errMsg = "JSON value is not an object";
if(errMsg != NULL) {
- dbgprintf("mmjsonparse: Error parsing JSON '%s': %s\n",
+ DBGPRINTF("mmjsonparse: Error parsing JSON '%s': %s\n",
buf, errMsg);
}
}
@@ -237,14 +245,6 @@ CODE_STD_STRING_REQUESTparseSelectorAct(1)
* the format specified (if any) is always ignored.
*/
CHKiRet(cflineParseTemplateName(&p, *ppOMSR, 0, OMSR_TPL_AS_MSG, (uchar*) "RSYSLOG_FileFormat"));
-
- /* finally build the instance */
- pData->tokener = json_tokener_new();
- if(pData->tokener == NULL) {
- errmsg.LogError(0, RS_RET_ERR, "error: could not create json "
- "tokener, cannot activate action");
- ABORT_FINALIZE(RS_RET_ERR);
- }
CODE_STD_FINALIZERparseSelectorAct
ENDparseSelectorAct