mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 13:45:38 +00:00
util: Fix resource leak
The virRotatingFileWriterAppend method leaks the file->entry
on the virRotatingFileWriterEntryNew failing path.
(cherry picked from commit 123770cd4e
)
This commit is contained in:
parent
0c20c9092c
commit
268c7e085a
@ -483,18 +483,19 @@ virRotatingFileWriterAppend(virRotatingFileWriterPtr file,
|
||||
|
||||
if ((file->entry->pos == file->maxlen && len) ||
|
||||
forceRollover) {
|
||||
virRotatingFileWriterEntryPtr tmp = file->entry;
|
||||
virRotatingFileWriterEntryPtr tmp;
|
||||
VIR_DEBUG("Hit max size %zu on %s (force=%d)\n",
|
||||
file->maxlen, file->basepath, forceRollover);
|
||||
|
||||
if (virRotatingFileWriterRollover(file) < 0)
|
||||
return -1;
|
||||
|
||||
if (!(file->entry = virRotatingFileWriterEntryNew(file->basepath,
|
||||
file->mode)))
|
||||
if (!(tmp = virRotatingFileWriterEntryNew(file->basepath,
|
||||
file->mode)))
|
||||
return -1;
|
||||
|
||||
virRotatingFileWriterEntryFree(tmp);
|
||||
virRotatingFileWriterEntryFree(file->entry);
|
||||
file->entry = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user