mirror of
https://github.com/php/php-src.git
synced 2026-04-12 18:43:37 +02:00
Make fgets not use maximal buffer length always, but shrink buffer
if it's too big.
This commit is contained in:
@@ -990,6 +990,10 @@ PHP_FUNCTION(fgets)
|
||||
} else {
|
||||
return_value->value.str.val = buf;
|
||||
return_value->value.str.len = strlen(return_value->value.str.val);
|
||||
/* resize buffer if it's much larger than the result */
|
||||
if(return_value->value.str.len < len/2) {
|
||||
return_value->value.str.val = erealloc(buf,return_value->value.str.len);
|
||||
}
|
||||
}
|
||||
return_value->type = IS_STRING;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user