[master] 81898e0 Fix memory leak on multiple -n / -N options
Martin Blix Grydeland
martin at varnish-cache.org
Thu Jun 13 12:41:23 CEST 2013
commit 81898e084881f35de039a8c9fa08db56449e4249
Author: Martin Blix Grydeland <martin at varnish-software.com>
Date: Thu May 23 14:40:30 2013 +0200
Fix memory leak on multiple -n / -N options
diff --git a/lib/libvarnishapi/vsm.c b/lib/libvarnishapi/vsm.c
index f0b2602..d7252fc 100644
--- a/lib/libvarnishapi/vsm.c
+++ b/lib/libvarnishapi/vsm.c
@@ -132,6 +132,11 @@ VSM_n_Arg(struct VSM_data *vd, const char *opt)
CHECK_OBJ_NOTNULL(vd, VSM_MAGIC);
AN(opt);
+ if (vd->fname) {
+ free(vd->fname);
+ vd->fname = NULL;
+ }
+ vd->N_opt = 0;
REPLACE(vd->n_opt, opt);
if (VIN_N_Arg(vd->n_opt, NULL, NULL, &vd->fname))
return (vsm_diag(vd, "Invalid instance name: %s\n",
@@ -148,6 +153,10 @@ VSM_N_Arg(struct VSM_data *vd, const char *opt)
CHECK_OBJ_NOTNULL(vd, VSM_MAGIC);
AN(opt);
+ if (vd->n_opt) {
+ free(vd->n_opt);
+ vd->n_opt = NULL;
+ }
REPLACE(vd->fname, opt);
vd->N_opt = 1;
return (1);
More information about the varnish-commit
mailing list