summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdio
diff options
context:
space:
mode:
authordas <das@FreeBSD.org>2008-06-29 23:46:06 +0000
committerdas <das@FreeBSD.org>2008-06-29 23:46:06 +0000
commit87e572f6a6752bfac60ac55ece334f3f38aa8338 (patch)
tree897de5512f72d4faaaea22d6530d088e9644e723 /lib/libc/stdio
parent68710b09906506ec69fe3b6af8f18df4227fb2b0 (diff)
downloadFreeBSD-src-87e572f6a6752bfac60ac55ece334f3f38aa8338.zip
FreeBSD-src-87e572f6a6752bfac60ac55ece334f3f38aa8338.tar.gz
Fix a bogon in the previous commit and add some missing error checks.
Diffstat (limited to 'lib/libc/stdio')
-rw-r--r--lib/libc/stdio/printf-pos.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/lib/libc/stdio/printf-pos.c b/lib/libc/stdio/printf-pos.c
index 6685abf..945ba61 100644
--- a/lib/libc/stdio/printf-pos.c
+++ b/lib/libc/stdio/printf-pos.c
@@ -130,7 +130,8 @@ static inline int
addtype(struct typetable *types, enum typeid type)
{
- _ensurespace(types);
+ if (_ensurespace(types))
+ return (-1);
types->table[types->nextarg++] = type;
return (0);
}
@@ -186,8 +187,6 @@ addaster(struct typetable *types, char **fmtp)
char *cp;
int n2;
- if (_ensurespace(types))
- return (-1);
n2 = 0;
cp = *fmtp;
while (is_digit(*cp)) {
@@ -197,11 +196,13 @@ addaster(struct typetable *types, char **fmtp)
if (*cp == '$') {
int hold = types->nextarg;
types->nextarg = n2;
- types->table[types->nextarg++] = T_INT;
+ if (addtype(types, T_INT))
+ return (-1);
types->nextarg = hold;
*fmtp = ++cp;
} else {
- types->table[types->nextarg++] = T_INT;
+ if (addtype(types, T_INT))
+ return (-1);
}
return (0);
}
@@ -212,8 +213,6 @@ addwaster(struct typetable *types, wchar_t **fmtp)
wchar_t *cp;
int n2;
- if (_ensurespace(types))
- return (-1);
n2 = 0;
cp = *fmtp;
while (is_digit(*cp)) {
@@ -223,11 +222,13 @@ addwaster(struct typetable *types, wchar_t **fmtp)
if (*cp == '$') {
int hold = types->nextarg;
types->nextarg = n2;
- types->table[types->nextarg++] = T_INT;
+ if (addtype(types, T_INT))
+ return (-1);
types->nextarg = hold;
*fmtp = ++cp;
} else {
- types->table[types->nextarg++] = T_INT;
+ if (addtype(types, T_INT))
+ return (-1);
}
return (0);
}
@@ -575,6 +576,8 @@ reswitch: switch (ch) {
error = addtype(&types, TP_SCHAR);
else
error = addtype(&types, TP_INT);
+ if (error)
+ goto error;
continue; /* no output */
case 'O':
flags |= LONGINT;
OpenPOWER on IntegriCloud