> > On Fri, Jul 21, 2017 at 02:01:12PM +0100, Frediano Ziglio wrote: > > The outer info_buf pointer were always NULL (the internal one > > is another variable). > > I'd expand a bit on what the leak is, at first I thought the short log > and long log were unrelated. > "log_version() declares 2 info_buf variables, the inner one is used to > hold allocated memory, but then we free the outer one, which is NULL." > > Looks good otherwise, > > Acked-by: Christophe Fergeau <cfergeau@xxxxxxxxxx> > > Christophe > > > > > Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx> > > --- > > OT: wonder why not using FindResource/LoadResource and so on instead > > of having to use the module file. > > --- > > common/vdlog.cpp | 9 ++++----- > > 1 file changed, 4 insertions(+), 5 deletions(-) > > > > diff --git a/common/vdlog.cpp b/common/vdlog.cpp > > index 76f4297..c983127 100644 > > --- a/common/vdlog.cpp > > +++ b/common/vdlog.cpp > > @@ -20,6 +20,7 @@ > > #include <stdio.h> > > #include <stdarg.h> > > #include <share.h> > > +#include <vector> > > > > #define LOG_ROLL_SIZE (1024 * 1024) > > > > @@ -80,7 +81,6 @@ void log_version() > > { > > DWORD handle; > > TCHAR module_fname[MAX_PATH]; > > - TCHAR* info_buf = NULL; > > > > try { > > if (!GetModuleFileName(NULL, module_fname, MAX_PATH)) { > > @@ -90,13 +90,13 @@ void log_version() > > if (version_inf_size == 0) { > > throw; Another OT... what's this throw? This is going to terminate the program, throw alone is for raising the current exception but there's no current exception here. > > } > > - TCHAR* info_buf = new TCHAR[version_inf_size]; > > - if (!GetFileVersionInfo(module_fname, handle, version_inf_size, > > info_buf)) { > > + std::vector<TCHAR> info_buf(version_inf_size); > > + if (!GetFileVersionInfo(module_fname, handle, version_inf_size, > > &info_buf[0])) { > > throw; > > } > > UINT size; > > VS_FIXEDFILEINFO* file_info; > > - if (!VerQueryValue(info_buf, L"\\", (VOID**)&file_info, &size) || > > + if (!VerQueryValue(&info_buf[0], L"\\", (VOID**)&file_info, &size) > > || > > size < sizeof(VS_FIXEDFILEINFO)) { > > throw; > > } > > @@ -108,5 +108,4 @@ void log_version() > > } catch (...) { > > vd_printf("get version info failed"); > > } > > - delete[] info_buf; > > } Frediano _______________________________________________ Spice-devel mailing list Spice-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/spice-devel