summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormillert <millert@openbsd.org>2007-09-10 19:40:49 +0000
committermillert <millert@openbsd.org>2007-09-10 19:40:49 +0000
commit2033bcffc8207cd742eba82af37f48d7c77d3a7d (patch)
tree13e72677fa5d1b1b29f2d1e60c83766fc10aa53b
parentremove my addition of portnumber for rsh in CVSROOT. (diff)
downloadwireguard-openbsd-2033bcffc8207cd742eba82af37f48d7c77d3a7d.tar.xz
wireguard-openbsd-2033bcffc8207cd742eba82af37f48d7c77d3a7d.zip
Use erealloc3() in more_aliases() instead of malloc/realloc.
-rw-r--r--usr.bin/sudo/parse.yacc22
1 files changed, 5 insertions, 17 deletions
diff --git a/usr.bin/sudo/parse.yacc b/usr.bin/sudo/parse.yacc
index a759212640d..5847e2f1272 100644
--- a/usr.bin/sudo/parse.yacc
+++ b/usr.bin/sudo/parse.yacc
@@ -54,9 +54,6 @@
# include <unistd.h>
#endif /* HAVE_UNISTD_H */
#include <pwd.h>
-#if defined(HAVE_MALLOC_H) && !defined(STDC_HEADERS)
-# include <malloc.h>
-#endif /* HAVE_MALLOC_H && !STDC_HEADERS */
#if defined(YYBISON) && defined(HAVE_ALLOCA_H) && !defined(__GNUC__)
# include <alloca.h>
#endif /* YYBISON && HAVE_ALLOCA_H && !__GNUC__ */
@@ -198,7 +195,7 @@ static void append __P((char *, char **, size_t *, size_t *, char *));
static void expand_ga_list __P((void));
static void expand_match_list __P((void));
static aliasinfo *find_alias __P((char *, int));
-static int more_aliases __P((void));
+static void more_aliases __P((void));
void init_parser __P((void));
void yyerror __P((char *));
@@ -964,12 +961,8 @@ add_alias(alias, type, val)
size_t onaliases;
char s[512];
- if (naliases >= nslots && !more_aliases()) {
- (void) snprintf(s, sizeof(s), "Out of memory defining alias `%s'",
- alias);
- yyerror(s);
- return(FALSE);
- }
+ if (naliases >= nslots)
+ more_aliases();
ai.type = type;
ai.val = val;
@@ -1013,17 +1006,12 @@ find_alias(alias, type)
/*
* Allocates more space for the aliases list.
*/
-static int
+static void
more_aliases()
{
nslots += MOREALIASES;
- if (nslots == MOREALIASES)
- aliases = (aliasinfo *) malloc(nslots * sizeof(aliasinfo));
- else
- aliases = (aliasinfo *) realloc(aliases, nslots * sizeof(aliasinfo));
-
- return(aliases != NULL);
+ aliases = (aliasinfo *) erealloc3(aliases, nslots, sizeof(aliasinfo));
}
/*