Re: trouble with g_stat

On Sun, Jun 03, 2018 at 10:27:48PM -0400, GaryW wrote:
My use of g_stat causes a segfault, but regular stat works ok. I’m using
mingw64 on Win10 under msys2.

GString *fspec;

GStatBuf *stBuf;

//fspec->str tested to hold the correct file spec…

if(g_stat(fspec->str,stBuf)<0){… [9476 Segmentation fault]

stBuf is an uninitialised pointer.  g_stat will try to write to the
address; undefined behaviour results.

Try allocating some memory of the right size, and assign that address
to the pointer before calling g_stat?

James Cameron

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