From a446780c65f14b0a321653de1bed3b597b95de0e Mon Sep 17 00:00:00 2001 From: oetiker Date: Thu, 29 Apr 2010 05:40:59 +0000 Subject: [PATCH] when using CDEF datasources in rrd, the rpnp in process_pdp_st (allocated in rpn_expand) in is never freed -- Frederik Kriewitz git-svn-id: svn://svn.oetiker.ch/rrdtool/branches/1.4@2073 a5681a0c-68f1-0310-ab6d-d61299d08faa --- program/src/rrd_rpncalc.c | 4 +++- program/src/rrd_update.c | 5 +++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/program/src/rrd_rpncalc.c b/program/src/rrd_rpncalc.c index e392a656..dca2ae13 100644 --- a/program/src/rrd_rpncalc.c +++ b/program/src/rrd_rpncalc.c @@ -72,8 +72,10 @@ rpnp_t *rpn_expand( /* DS_CDEF_MAX_RPN_NODES is small, so at the expense of some wasted * memory we avoid any reallocs */ rpnp = (rpnp_t *) calloc(DS_CDEF_MAX_RPN_NODES, sizeof(rpnp_t)); - if (rpnp == NULL) + if (rpnp == NULL) { + rrd_set_error("failed allocating rpnp array"); return NULL; + } for (i = 0; rpnc[i].op != OP_END; ++i) { rpnp[i].op = rpnc[i].op; if (rpnp[i].op == OP_NUMBER) { diff --git a/program/src/rrd_update.c b/program/src/rrd_update.c index 4016d757..0335a9ef 100644 --- a/program/src/rrd_update.c +++ b/program/src/rrd_update.c @@ -1354,6 +1354,10 @@ static int process_pdp_st( rpnp = rpn_expand((rpn_cdefds_t *) &(rrd->ds_def[ds_idx].par[DS_cdef])); + if(rpnp == NULL) { + rpnstack_free(&rpnstack); + return -1; + } /* substitute data values for OP_VARIABLE nodes */ for (i = 0; rpnp[i].op != OP_END; i++) { if (rpnp[i].op == OP_VARIABLE) { @@ -1367,6 +1371,7 @@ static int process_pdp_st( rpnstack_free(&rpnstack); return -1; } + free(rpnp); } /* make pdp_prep ready for the next run */ -- 2.30.2