Skip to content

Commit

Permalink
cimg::load_network(): Try to fix double-free.
Browse files Browse the repository at this point in the history
  • Loading branch information
dtschump committed May 11, 2024
1 parent 9597113 commit e2ca0a4
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions CImg.h
Original file line number Diff line number Diff line change
Expand Up @@ -68285,6 +68285,7 @@ namespace cimg_library {
cimg::temporary_path(),cimg_file_separator,cimg::filenamerand(),ext._data);
if ((file = cimg::std_fopen(filename_local,"rb"))!=0) cimg::fclose(file);
} while (file);
file = 0;

#ifdef cimg_use_curl
const unsigned int omode = cimg::exception_mode();
Expand All @@ -68311,10 +68312,9 @@ namespace cimg_library {
cimg::fseek(file,0,SEEK_END); // Check if file size is 0
const cimg_ulong siz = cimg::ftell(file);
cimg::fclose(file);
if (siz>0 && res==CURLE_OK) {
cimg::exception_mode(omode);
return filename_local;
} else std::remove(filename_local);
file = 0;
if (siz>0 && res==CURLE_OK) { cimg::exception_mode(omode); return filename_local; }
else std::remove(filename_local);
}
} catch (...) { }
cimg::exception_mode(omode);
Expand Down Expand Up @@ -68373,7 +68373,6 @@ namespace cimg_library {
#else
"'wget' or 'curl'.",url);
#endif
cimg::fclose(file);

// Try gunzip it.
cimg_snprintf(command,command._width,"%s.gz",filename_local);
Expand Down

0 comments on commit e2ca0a4

Please sign in to comment.