mirror of
https://github.com/rsyslog/rsyslog.git
synced 2025-12-21 02:00:42 +01:00
fixed segfault when pure string values were tried to be added
This commit is contained in:
parent
50ddd3fd7d
commit
ee7a17a679
13
var.c
13
var.c
@ -178,10 +178,7 @@ finalize_it:
|
||||
}
|
||||
|
||||
|
||||
/* check if the provided object can be converted to a number. Uses
|
||||
* non-standard calling conventions because it makes an awful lot of sense.
|
||||
* Returns 1 if conversion is possibe and 0 if not. If 1 is returned, a
|
||||
* conversion request on the unchanged object is guaranteed to succeed.
|
||||
/* Change the provided object to be of type number.
|
||||
* rgerhards, 2008-02-22
|
||||
*/
|
||||
rsRetVal
|
||||
@ -193,7 +190,13 @@ ConvToNumber(var_t *pThis)
|
||||
if(pThis->varType == VARTYPE_NUMBER) {
|
||||
FINALIZE;
|
||||
} else if(pThis->varType == VARTYPE_STR) {
|
||||
CHKiRet(rsCStrConvertToNumber(pThis->val.pStr, &n));
|
||||
iRet = rsCStrConvertToNumber(pThis->val.pStr, &n);
|
||||
if(iRet == RS_RET_NOT_A_NUMBER) {
|
||||
n = 0; /* TODO: isn't it better to pass the error? */
|
||||
} else if (iRet != RS_RET_OK) {
|
||||
FINALIZE;
|
||||
}
|
||||
|
||||
pThis->val.num = n;
|
||||
pThis->varType = VARTYPE_NUMBER;
|
||||
}
|
||||
|
||||
13
vm.c
13
vm.c
@ -82,7 +82,7 @@ BOOLOP(AND, &&)
|
||||
|
||||
|
||||
/* code generator for numerical operations */
|
||||
#define BOOLOP(name, OPERATION) \
|
||||
#define NUMOP(name, OPERATION) \
|
||||
BEGINop(name) /* remember to set the instruction also in the ENDop macro! */ \
|
||||
var_t *operand1; \
|
||||
var_t *operand2; \
|
||||
@ -90,15 +90,14 @@ CODESTARTop(name) \
|
||||
vmstk.PopNumber(pThis->pStk, &operand1); \
|
||||
vmstk.PopNumber(pThis->pStk, &operand2); \
|
||||
operand1->val.num = operand1->val.num OPERATION operand2->val.num; \
|
||||
RUNLOG_VAR("%lld", operand1->val.num); \
|
||||
vmstk.Push(pThis->pStk, operand1); /* result */ \
|
||||
var.Destruct(&operand2); /* no longer needed */ \
|
||||
ENDop(name)
|
||||
BOOLOP(PLUS, +)
|
||||
BOOLOP(MINUS, -)
|
||||
BOOLOP(TIMES, *)
|
||||
BOOLOP(DIV, /)
|
||||
BOOLOP(MOD, %)
|
||||
NUMOP(PLUS, +)
|
||||
NUMOP(MINUS, -)
|
||||
NUMOP(TIMES, *)
|
||||
NUMOP(DIV, /)
|
||||
NUMOP(MOD, %)
|
||||
#undef BOOLOP
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user