Arjen de Korte
2011-Jan-18 10:32 UTC
[Nut-upsdev] [nut-commits] svn commit r2839 - branches/windows_port/scripts/Windows
Citeren Frederic BOHE <fbohe-guest op alioth.debian.org>:> --- branches/windows_port/scripts/Windows/wininit.c Tue Jan 18 > 08:57:03 2011 (r2838) > +++ branches/windows_port/scripts/Windows/wininit.c Tue Jan 18 > 10:05:01 2011 (r2839) > @@ -285,8 +285,11 @@ > char fn[SMALLBUF]; > FILE *nutf; > char buf[SMALLBUF]; > + const char * conf_path; > > - snprintf(fn,sizeof(fn),"%s/nut.conf",CONFPATH); > + conf_path = confpath(); > + snprintf(fn,sizeof(fn),"%s/nut.conf",conf_path); > + free(conf_path);This won't work. You can't free() conf_path here, since it is not dynamically allocated. Use snprintf(fn, sizeof(fn), "%s/nut.conf", confpath()); instead. Best regards, Arjen -- Please keep list traffic on the list (off-list replies will be rejected)
Frédéric Bohé
2011-Jan-18 12:43 UTC
[Nut-upsdev] [nut-commits] svn commit r2839 - branches/windows_port/scripts/Windows
On mar., 2011-01-18 at 11:32 +0100, Arjen de Korte wrote:> Citeren Frederic BOHE <fbohe-guest at alioth.debian.org>: > > > --- branches/windows_port/scripts/Windows/wininit.c Tue Jan 18 > > 08:57:03 2011 (r2838) > > +++ branches/windows_port/scripts/Windows/wininit.c Tue Jan 18 > > 10:05:01 2011 (r2839) > > @@ -285,8 +285,11 @@ > > char fn[SMALLBUF]; > > FILE *nutf; > > char buf[SMALLBUF]; > > + const char * conf_path; > > > > - snprintf(fn,sizeof(fn),"%s/nut.conf",CONFPATH); > > + conf_path = confpath(); > > + snprintf(fn,sizeof(fn),"%s/nut.conf",conf_path); > > + free(conf_path); > > This won't work. You can't free() conf_path here, since it is not > dynamically allocated. Use > > snprintf(fn, sizeof(fn), "%s/nut.conf", confpath()); > > instead.confpath() does return a dynamically allocated string in WIN32. But if memory allocation fails it falls back to CONFPATH, in which case there is indeed a bug. I will fix this. --------------------------------------------------------------------------