[rrd-developers] [PATCH] rrd_update: fix memory leak during CDEF processing
Tobias Oetiker
tobi at oetiker.ch
Thu Apr 29 07:41:28 CEST 2010
Hi Frederik,
makes sense ... (I guess CDEF DSes are not used a lot)
thanks
tobi
Yesterday Frederik Kriewitz wrote:
> I think rpnp in process_pdp_st (allocated in rpn_expand) in is never freed.
>
> Index: src/rrd_update.c
> ===================================================================
> --- src/rrd_update.c (revision 2072)
> +++ src/rrd_update.c (working copy)
> @@ -1354,6 +1354,10 @@
>
> 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 @@
> rpnstack_free(&rpnstack);
> return -1;
> }
> + free(rpnp);
> }
>
> /* make pdp_prep ready for the next run */
> Index: src/rrd_rpncalc.c
> ===================================================================
> --- src/rrd_rpncalc.c (revision 2072)
> +++ src/rrd_rpncalc.c (working copy)
> @@ -72,8 +72,10 @@
> /* 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) {
>
> _______________________________________________
> rrd-developers mailing list
> rrd-developers at lists.oetiker.ch
> https://lists.oetiker.ch/cgi-bin/listinfo/rrd-developers
>
>
--
Tobi Oetiker, OETIKER+PARTNER AG, Aarweg 15 CH-4600 Olten, Switzerland
http://it.oetiker.ch tobi at oetiker.ch ++41 62 775 9902 / sb: -9900
More information about the rrd-developers
mailing list