Make sure that each va_start has one and only one matching va_end,

especially in error cases.
This commit is contained in:
Kevin Lo 2012-05-29 01:48:06 +00:00
parent bebda077b1
commit 544c5e5b53
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=236213
8 changed files with 13 additions and 0 deletions

View file

@ -138,6 +138,7 @@ ask(int def, const char *fmt, ...)
va_start(ap, fmt);
vsnprintf(prompt, sizeof(prompt), fmt, ap);
va_end(ap);
if (alwaysyes || rdonly) {
printf("%s? %s\n", prompt, rdonly ? "no" : "yes");
return !rdonly;

View file

@ -411,6 +411,7 @@ panic(const char *fmt, ...)
va_list ap;
va_start(ap, fmt);
vfprintf(stderr, fmt, ap);
va_end(ap);
if (yflag)
return;
if (reply("abort") == GOOD) {

View file

@ -276,6 +276,7 @@ biospnp_call(int func, const char *fmt, ...)
break;
}
}
va_end(ap);
/* BIOS segment last */
*(u_int16_t *)argp = pnp_Icheck->pnp_rmds;

View file

@ -3591,6 +3591,7 @@ DbgPrint(char *fmt, ...)
if (bootverbose) {
va_start(ap, fmt);
vprintf(fmt, ap);
va_end(ap);
}
return (STATUS_SUCCESS);

View file

@ -372,9 +372,11 @@ bios16(struct bios_args *args, char *fmt, ...)
break;
default:
va_end(ap);
return (EINVAL);
}
}
va_end(ap);
if (flags & BIOSARGS_FLAG) {
if (arg_end - arg_start > ctob(16))
@ -448,9 +450,11 @@ bios16(struct bios_args *args, char *fmt, ...)
break;
default:
va_end(ap);
return (EINVAL);
}
}
va_end(ap);
set_bios_selectors(&args->seg, flags);
bioscall_vector.vec16.offset = (u_short)args->entry;

View file

@ -408,6 +408,7 @@ chat_logf(const char *fmt, ...)
va_start(args, fmt);
vfmtmsg(line, sizeof(line), fmt, args);
va_end(args);
if (to_log)
syslog(LOG_INFO, "%s", line);
if (to_stderr)
@ -425,6 +426,7 @@ fatal(int code, const char *fmt, ...)
va_start(args, fmt);
vfmtmsg(line, sizeof(line), fmt, args);
va_end(args);
if (to_log)
syslog(LOG_ERR, "%s", line);
if (to_stderr)

View file

@ -47,6 +47,7 @@ vsystem(const char *fmt, ...)
va_start(args, fmt);
if (vsnprintf(cmd, maxargs, fmt, args) > maxargs) {
warnx("vsystem args are too long");
va_end(args);
return 1;
}
#ifdef DEBUG
@ -82,6 +83,7 @@ vpipe(const char *fmt, ...)
va_start(args, fmt);
if (vsnprintf(cmd, maxargs, fmt, args) > maxargs) {
warnx("vsystem args are too long");
va_end(args);
return NULL;
}
#ifdef DEBUG

View file

@ -71,5 +71,6 @@ y_or_n(Boolean def, const char *msg, ...)
ch = (def) ? 'Y' : 'N';
}
fclose(tty) ;
va_end(args);
return (ch == 'Y') ? TRUE : FALSE;
}