зеркало из https://github.com/Azure/sonic-openssh.git
Defer setting bufsiz in getdelim.
Do not write to bufsiz until we are sure the malloc has succeeded, in case any callers rely on it (which they shouldn't). ok djm@
This commit is contained in:
Родитель
3deb56f719
Коммит
872517ddbb
|
@ -53,9 +53,9 @@ getdelim(char **buf, size_t *bufsiz, int delimiter, FILE *fp)
|
|||
|
||||
|
||||
if (*buf == NULL || *bufsiz == 0) {
|
||||
*bufsiz = BUFSIZ;
|
||||
if ((*buf = malloc(*bufsiz)) == NULL)
|
||||
if ((*buf = malloc(BUFSIZ)) == NULL)
|
||||
return -1;
|
||||
*bufsiz = BUFSIZ;
|
||||
}
|
||||
|
||||
for (ptr = *buf, eptr = *buf + *bufsiz;;) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче