Add function name to memory allocation warnings.
}
goto bad;
}
- paths = malloc(sizeof(*paths) * max_paths);
- if (paths == NULL)
+ paths = reallocarray(NULL, max_paths, sizeof(*paths));
+ if (paths == NULL) {
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
goto bad;
+ }
while ((dent = readdir(dir)) != NULL) {
struct path_list *pl;
struct stat sb;
}
pl = malloc(sizeof(*pl));
if (pl == NULL) {
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
free(path);
goto bad;
}
max_paths <<= 1;
tmp = reallocarray(paths, max_paths, sizeof(*paths));
if (tmp == NULL) {
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
free(path);
free(pl);
goto bad;
istacksize += SUDOERS_STACK_INCREMENT;
new_istack = reallocarray(istack, istacksize, sizeof(*istack));
if (new_istack == NULL) {
- sudo_warn(NULL);
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
sudoerserror(NULL);
debug_return_bool(false);
}
len += (int)(ep - cp);
path = pp = malloc(len + dirlen + 1);
if (path == NULL) {
- sudo_warn(NULL);
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
sudoerserror(NULL);
debug_return_str(NULL);
}
}
goto bad;
}
- paths = malloc(sizeof(*paths) * max_paths);
- if (paths == NULL)
+ paths = reallocarray(NULL, max_paths, sizeof(*paths));
+ if (paths == NULL) {
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
goto bad;
+ }
while ((dent = readdir(dir)) != NULL) {
struct path_list *pl;
struct stat sb;
}
pl = malloc(sizeof(*pl));
if (pl == NULL) {
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
free(path);
goto bad;
}
max_paths <<= 1;
tmp = reallocarray(paths, max_paths, sizeof(*paths));
if (tmp == NULL) {
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
free(path);
free(pl);
goto bad;
istacksize += SUDOERS_STACK_INCREMENT;
new_istack = reallocarray(istack, istacksize, sizeof(*istack));
if (new_istack == NULL) {
- sudo_warn(NULL);
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
sudoerserror(NULL);
debug_return_bool(false);
}
len += (int)(ep - cp);
path = pp = malloc(len + dirlen + 1);
if (path == NULL) {
- sudo_warn(NULL);
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
sudoerserror(NULL);
debug_return_str(NULL);
}
dst = olen ? realloc(sudoerslval.string, olen + len + 1) : malloc(len + 1);
if (dst == NULL) {
- sudo_warn(NULL);
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
sudoerserror(NULL);
debug_return_bool(false);
}
dst = sudoerslval.command.cmnd = malloc(len + 1);
if (sudoerslval.command.cmnd == NULL) {
- sudo_warn(NULL);
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
sudoerserror(NULL);
debug_return_bool(false);
}
p = realloc(sudoerslval.command.args, arg_size);
if (p == NULL) {
- free(sudoerslval.command.args);
- sudo_warn(NULL);
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
sudoerserror(NULL);
+ free(sudoerslval.command.args);
debug_return_bool(false);
} else
sudoerslval.command.args = p;