Re: [vdagent-win PATCH] Remove small memory leak in log_version

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Jul 21, 2017 at 09:58:59AM -0400, Frediano Ziglio wrote:
> > 
> > >  
> > >  #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.

I'd say the goal was to go to the catch(...) block below, just not done
correctly.

> 
> > >          }
> > > -        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

Attachment: signature.asc
Description: PGP signature

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel

[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]