mirror of
https://github.com/sudo-project/sudo.git
synced 2025-09-01 14:55:12 +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;
|
bufsize = *bufp ? *bufsizep : 0;
|
||||||
if (bufsize == 0 || bufsize - 1 < len) {
|
if (bufsize == 0 || bufsize - 1 < len) {
|
||||||
bufsize = len + 1;
|
bufsize = len + 1;
|
||||||
cp = *bufp ? realloc(*bufp, bufsize) : malloc(bufsize);
|
cp = realloc(*bufp, bufsize);
|
||||||
if (cp == NULL)
|
if (cp == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
*bufp = cp;
|
*bufp = cp;
|
||||||
@@ -68,7 +68,7 @@ sudo_getline(char **bufp, size_t *bufsizep, FILE *fp)
|
|||||||
bufsize = *bufsizep;
|
bufsize = *bufsizep;
|
||||||
if (buf == NULL || bufsize == 0) {
|
if (buf == NULL || bufsize == 0) {
|
||||||
bufsize = LINE_MAX;
|
bufsize = LINE_MAX;
|
||||||
cp = buf ? realloc(buf, bufsize) : malloc(bufsize);
|
cp = realloc(buf, bufsize);
|
||||||
if (cp == NULL)
|
if (cp == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
buf = cp;
|
buf = cp;
|
||||||
|
@@ -142,10 +142,9 @@ fill_args(const char *s, int len, int addspace)
|
|||||||
if (new_len >= arg_size) {
|
if (new_len >= arg_size) {
|
||||||
/* Allocate more space than we need for subsequent args */
|
/* Allocate more space than we need for subsequent args */
|
||||||
while (new_len >= (arg_size += COMMANDARGINC))
|
while (new_len >= (arg_size += COMMANDARGINC))
|
||||||
;
|
continue;
|
||||||
|
|
||||||
p = sudoerslval.command.args ?
|
p = realloc(sudoerslval.command.args, arg_size);
|
||||||
realloc(sudoerslval.command.args, arg_size) : malloc(arg_size);
|
|
||||||
if (p == NULL) {
|
if (p == NULL) {
|
||||||
free(sudoerslval.command.args);
|
free(sudoerslval.command.args);
|
||||||
sudo_warn(NULL);
|
sudo_warn(NULL);
|
||||||
|
Reference in New Issue
Block a user