diff options
| author | David Schultz <das@FreeBSD.org> | 2008-06-29 23:46:06 +0000 |
|---|---|---|
| committer | David Schultz <das@FreeBSD.org> | 2008-06-29 23:46:06 +0000 |
| commit | c4014b50867e6dfa1abab5b8400b0ad60bb7f5c5 (patch) | |
| tree | 897de5512f72d4faaaea22d6530d088e9644e723 /lib/libc | |
| parent | e62e5ff93f7d3aa26a498650a74709f6ff28845b (diff) | |
Notes
Diffstat (limited to 'lib/libc')
| -rw-r--r-- | lib/libc/stdio/printf-pos.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/lib/libc/stdio/printf-pos.c b/lib/libc/stdio/printf-pos.c index 6685abfad570..945ba61b78be 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; |
