Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/kern Make sure va_end is used even when errors are encou...
details: https://anonhg.NetBSD.org/src/rev/8d8ed3115bd5
branches: trunk
changeset: 779629:8d8ed3115bd5
user: matt <matt%NetBSD.org@localhost>
date: Wed Jun 06 05:10:54 2012 +0000
description:
Make sure va_end is used even when errors are encountered.
diffstat:
sys/kern/kern_sysctl.c | 21 ++++++++++++++-------
1 files changed, 14 insertions(+), 7 deletions(-)
diffs (50 lines):
diff -r a2cf3a02a9cf -r 8d8ed3115bd5 sys/kern/kern_sysctl.c
--- a/sys/kern/kern_sysctl.c Wed Jun 06 00:34:32 2012 +0000
+++ b/sys/kern/kern_sysctl.c Wed Jun 06 05:10:54 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_sysctl.c,v 1.235 2012/06/02 21:36:46 dsl Exp $ */
+/* $NetBSD: kern_sysctl.c,v 1.236 2012/06/06 05:10:54 matt Exp $ */
/*-
* Copyright (c) 2003, 2007, 2008 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_sysctl.c,v 1.235 2012/06/02 21:36:46 dsl Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_sysctl.c,v 1.236 2012/06/06 05:10:54 matt Exp $");
#include "opt_defcorename.h"
#include "ksyms.h"
@@ -1957,19 +1957,26 @@
*/
va_start(ap, newlen);
namelen = 0;
+ error = 0;
ni = -1;
do {
- if (++ni == CTL_MAXNAME)
- return (ENAMETOOLONG);
+ if (++ni == CTL_MAXNAME) {
+ error = ENAMETOOLONG;
+ break;
+ }
name[ni] = va_arg(ap, int);
/*
* sorry, this is not supported from here
*/
- if (name[ni] == CTL_CREATESYM)
- return (EINVAL);
+ if (name[ni] == CTL_CREATESYM) {
+ error = EINVAL;
+ break;
+ }
} while (name[ni] != CTL_EOL && name[ni] != CTL_CREATE);
+ va_end(ap);
+ if (error)
+ return error;
namelen = ni + (name[ni] == CTL_CREATE ? 1 : 0);
- va_end(ap);
/*
* what's it called
Home |
Main Index |
Thread Index |
Old Index