c++ - FILE* access violation -
i have annoying access violation problem visual studio 2012. had same problem in visual studio 2010 , thought compiler problem turns out not.
here part of code gives me access violation:
sdl_surface *cgraphicsmanager::loadimagefrompak(char *filename, char *img_type) { // load 'file' sdl_surface sdl_surface *img = null; char errorname[50]; sprintf(errorname, "unable load image %s pakfile", filename); file *fin = pakfile.open_file(filename); if(!fin) { errorlog(errorname); return null; } sdl_rwops *rw; rw = sdl_rwfromfp(fin, 1); if (!rw) { errorlog("erro na linha 213"); return null; } img = img_loadtyped_rw(rw,0, img_type); // crashes on line if(img == null) errorlog("unable load image pakfile."); sdl_freerw(rw); //pakfile.close_mpk(); //if (img_type == "png") img = add_transparency(img); return img; }
it gives me access violation writing @ location 0x00000014. weird thing compiles , runs fine on mingw compiler, makes me think not wrong code. read problem file* , dll calls didnt find how fix that. have no linking warnings , have linked necesary libs. running in debug mode , compiling in multi-threaded debug dll (mdd). visual studio faster writing code , easier debugging mingw , appreciate response. thank much.
the address telling - code dereferencing null pointer access member that's 0x14 (20)
bytes object address. sniff around contents of rw
parameter. may not null, may contain member is. i'd recommend using debugger halt on crash can inspect call stack. 1 last suggestion - if you're using third-party library, may need kind of initialization call set global state. failure might cause crash (personal experience).
Comments
Post a Comment