提交 123770cd 编写于 作者: W Wang King 提交者: John Ferlan

util: Fix resource leak

The virRotatingFileWriterAppend method leaks the file->entry
on the virRotatingFileWriterEntryNew failing path.
上级 9db0a63b
......@@ -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,
if (!(tmp = virRotatingFileWriterEntryNew(file->basepath,
file->mode)))
return -1;
virRotatingFileWriterEntryFree(tmp);
virRotatingFileWriterEntryFree(file->entry);
file->entry = tmp;
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册