- Fixed "segmentation fault" if it is not possible to write to file

git-svn-id: svn://kolibrios.org@8716 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
turbocat 2021-05-09 20:14:40 +00:00
parent c080568a52
commit 86ba0f80f2

View File

@ -260,7 +260,10 @@ int tcc_output_me(TCCState* s1,const char *filename)
me.header.params= tcc_find_symbol_me(&me,"__argv"); // <--
me.header.argv= tcc_find_symbol_me(&me,"__path"); // <--
f=fopen(filename,"wb");
if((f=fopen(filename,"wb"))==NULL){
tcc_error("could not create '%s': %s", filename, strerror(errno));
}
for (i=0;i<8;i++)
me.header.magic[i]=me_magic[i];
fwrite(&me.header,1,sizeof(IMAGE_MEOS_FILE_HEADER),f);