From b03ae3024d1e1e7f66afeaa8f2e2638336088c8d Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Wed, 4 Jun 2008 06:26:16 +0300 Subject: [PATCH] dpkg: Fix memory leaks if archivefiles is called more than once Use varbufreset instead of varbufinit, as the variables are global. --- ChangeLog | 5 +++++ src/archives.c | 8 +++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2e937700..b683f064 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2008-06-04 Guillem Jover + + * src/archives.c (archivefiles): Use varbufreset instead of varbufinit + to avoid possible leaks if this function is called more than once. + 2008-06-04 Guillem Jover * lib/log.c (log_message): Switch log from a pointer to struct varbuf diff --git a/src/archives.c b/src/archives.c index 5124e1ff..a2022445 100644 --- a/src/archives.c +++ b/src/archives.c @@ -1173,9 +1173,11 @@ void archivefiles(const char *const *argv) { currenttime = time(NULL); - varbufinit(&fnamevb); - varbufinit(&fnametmpvb); - varbufinit(&fnamenewvb); + /* Initialize fname variables contents. */ + + varbufreset(&fnamevb); + varbufreset(&fnametmpvb); + varbufreset(&fnamenewvb); varbufaddstr(&fnamevb,instdir); varbufaddc(&fnamevb,'/'); varbufaddstr(&fnametmpvb,instdir); varbufaddc(&fnametmpvb,'/'); -- 2.39.5