mirror of
https://github.com/sudo-project/sudo.git
synced 2025-08-31 06:15:37 +00:00
It's safe to rely on C89 semantics for realloc(NULL, size).
This commit is contained in:
@@ -45,7 +45,7 @@ sudo_getline(char **bufp, size_t *bufsizep, FILE *fp)
|
||||
bufsize = *bufp ? *bufsizep : 0;
|
||||
if (bufsize == 0 || bufsize - 1 < len) {
|
||||
bufsize = len + 1;
|
||||
cp = *bufp ? realloc(*bufp, bufsize) : malloc(bufsize);
|
||||
cp = realloc(*bufp, bufsize);
|
||||
if (cp == NULL)
|
||||
return -1;
|
||||
*bufp = cp;
|
||||
@@ -68,7 +68,7 @@ sudo_getline(char **bufp, size_t *bufsizep, FILE *fp)
|
||||
bufsize = *bufsizep;
|
||||
if (buf == NULL || bufsize == 0) {
|
||||
bufsize = LINE_MAX;
|
||||
cp = buf ? realloc(buf, bufsize) : malloc(bufsize);
|
||||
cp = realloc(buf, bufsize);
|
||||
if (cp == NULL)
|
||||
return -1;
|
||||
buf = cp;
|
||||
|
@@ -142,10 +142,9 @@ fill_args(const char *s, int len, int addspace)
|
||||
if (new_len >= arg_size) {
|
||||
/* Allocate more space than we need for subsequent args */
|
||||
while (new_len >= (arg_size += COMMANDARGINC))
|
||||
;
|
||||
continue;
|
||||
|
||||
p = sudoerslval.command.args ?
|
||||
realloc(sudoerslval.command.args, arg_size) : malloc(arg_size);
|
||||
p = realloc(sudoerslval.command.args, arg_size);
|
||||
if (p == NULL) {
|
||||
free(sudoerslval.command.args);
|
||||
sudo_warn(NULL);
|
||||
|
Reference in New Issue
Block a user