From 86ba0f80f2c98520e95225da0dcf2a39cd01b8ef Mon Sep 17 00:00:00 2001 From: turbocat Date: Sun, 9 May 2021 20:14:40 +0000 Subject: [PATCH] ktcc: - Fixed "segmentation fault" if it is not possible to write to file git-svn-id: svn://kolibrios.org@8716 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/develop/ktcc/trunk/source/tccmeos.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/programs/develop/ktcc/trunk/source/tccmeos.c b/programs/develop/ktcc/trunk/source/tccmeos.c index c0756a7f07..d7efe46b28 100644 --- a/programs/develop/ktcc/trunk/source/tccmeos.c +++ b/programs/develop/ktcc/trunk/source/tccmeos.c @@ -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);