[collectd] [PATCH] perl plugin: Do not abort while preparing the stack for a subroutine call.

Sebastian Harl sh at tokkee.org
Sat Feb 16 14:09:36 CET 2008


Else the stack would probably be left in an inconsistent case and might even
leak memory.

Signed-off-by: Sebastian Harl <sh at tokkee.org>
---
 src/perl.c |   24 ++++++++++++++++++------
 1 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/src/perl.c b/src/perl.c
index 3c50528..7558a50 100644
--- a/src/perl.c
+++ b/src/perl.c
@@ -700,11 +700,19 @@ static int pplugin_call_all (pTHX_ int type, ...)
 		ds = va_arg (ap, data_set_t *);
 		vl = va_arg (ap, value_list_t *);
 
-		if (-1 == data_set2av (aTHX_ ds, pds))
-			return -1;
+		if (-1 == data_set2av (aTHX_ ds, pds)) {
+			av_clear (pds);
+			av_undef (pds);
+			pds = Nullav;
+			ret = -1;
+		}
 
-		if (-1 == value_list2hv (aTHX_ vl, ds, pvl))
-			return -1;
+		if (-1 == value_list2hv (aTHX_ vl, ds, pvl)) {
+			hv_clear (pvl);
+			hv_undef (pvl);
+			pvl = Nullhv;
+			ret = -1;
+		}
 
 		XPUSHs (sv_2mortal (newSVpv (ds->type, 0)));
 		XPUSHs (sv_2mortal (newRV_noinc ((SV *)pds)));
@@ -738,8 +746,12 @@ static int pplugin_call_all (pTHX_ int type, ...)
 
 		n = va_arg (ap, notification_t *);
 
-		if (-1 == notification2hv (aTHX_ n, notif))
-			return -1;
+		if (-1 == notification2hv (aTHX_ n, notif)) {
+			hv_clear (notif);
+			hv_undef (notif);
+			notif = Nullhv;
+			ret = -1;
+		}
 
 		XPUSHs (sv_2mortal (newRV_noinc ((SV *)notif)));
 	}
-- 
1.5.4.23.gef5b9

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://mailman.verplant.org/pipermail/collectd/attachments/20080216/ccb5e45c/attachment.pgp 


More information about the collectd mailing list