mirror of
https://github.com/mirror/tinycc.git
synced 2025-01-29 06:10:09 +08:00
Add some missing fdopen(3) checks (Domingo Alvarez Duarte)
This commit is contained in:
parent
308d8d17dc
commit
917aad3bcf
5
tccelf.c
5
tccelf.c
@ -2423,11 +2423,10 @@ static int tcc_write_elf_file(TCCState *s1, const char *filename, int phnum,
|
||||
mode = 0777;
|
||||
unlink(filename);
|
||||
fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, mode);
|
||||
if (fd < 0) {
|
||||
tcc_error_noabort("could not write '%s'", filename);
|
||||
if (fd < 0 || (f = fdopen(fd, "wb")) == NULL) {
|
||||
tcc_error_noabort("could not write or fdopen '%s'", filename);
|
||||
return -1;
|
||||
}
|
||||
f = fdopen(fd, "wb");
|
||||
if (s1->verbose)
|
||||
printf("<- %s\n", filename);
|
||||
|
||||
|
@ -795,11 +795,10 @@ ST_FUNC int macho_output_file(TCCState *s1, const char *filename)
|
||||
mode = 0777;
|
||||
unlink(filename);
|
||||
fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, mode);
|
||||
if (fd < 0) {
|
||||
if (fd < 0 || (fp = fdopen(fd, "wb")) == NULL) {
|
||||
tcc_error_noabort("could not write '%s: %s'", filename, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
fp = fdopen(fd, "wb");
|
||||
if (s1->verbose)
|
||||
printf("<- %s\n", filename);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user