mirror of
https://github.com/php/php-src.git
synced 2024-11-24 10:24:11 +08:00
Fixed possible crash on fstat() failure.
This commit is contained in:
parent
890afc455c
commit
cb16f5e815
@ -871,7 +871,10 @@ PHP_FUNCTION(fdf_save_string)
|
||||
struct stat stat;
|
||||
char *buf;
|
||||
|
||||
fstat(fileno(fp), &stat);
|
||||
if (fstat(fileno(fp), &stat) == -1) {
|
||||
RETVAL_FALSE;
|
||||
goto err;
|
||||
}
|
||||
buf = emalloc(stat.st_size +1);
|
||||
fread(buf, stat.st_size, 1, fp);
|
||||
buf[stat.st_size] = '\0';
|
||||
@ -889,7 +892,7 @@ PHP_FUNCTION(fdf_save_string)
|
||||
if(err != FDFErcOK) {
|
||||
FDF_FAILURE(err);
|
||||
}
|
||||
|
||||
err:
|
||||
if(temp_filename) {
|
||||
unlink(temp_filename);
|
||||
efree(temp_filename);
|
||||
|
Loading…
Reference in New Issue
Block a user