summaryrefslogtreecommitdiff
path: root/gcc/c-format.c
diff options
context:
space:
mode:
authorDan Hipschman <dsh@google.com>2007-08-13 14:55:01 -0700
committerDan Hipschman <dsh@gcc.gnu.org>2007-08-13 14:55:01 -0700
commitd46571c803a80a1ee0b7360f0667a8e315a9b959 (patch)
tree278e6dbd480b49a8489a8b858c2faeb7bea5386b /gcc/c-format.c
parenteda0ed2597cfab9c967d229b7df2986ef92e663d (diff)
downloadgcc-d46571c803a80a1ee0b7360f0667a8e315a9b959.tar.gz
2007-08-3 1 Dan Hipschman <dsh@google.com>
gcc/ 2007-08-3 1 Dan Hipschman <dsh@google.com> PR 32953 * c-format.c (check_format_arg): Move check for zero-length format strings below the check for unterminated strings. testsuite/ 2007-08-13 Dan Hipschman <dsh@google.com> PR 32953 * gcc.dg/format/array-1.c: Add an additional test for unterminated format strings of length 1. From-SVN: r127399
Diffstat (limited to 'gcc/c-format.c')
-rw-r--r--gcc/c-format.c9
1 files changed, 2 insertions, 7 deletions
diff --git a/gcc/c-format.c b/gcc/c-format.c
index 8a36dd412fb..a4965418d53 100644
--- a/gcc/c-format.c
+++ b/gcc/c-format.c
@@ -1401,21 +1401,16 @@ check_format_arg (void *ctx, tree format_tree,
format_chars += offset;
format_length -= offset;
}
- if (format_length < 1)
+ if (format_length < 1 || format_chars[--format_length] != 0)
{
res->number_unterminated++;
return;
}
- if (format_length == 1)
+ if (format_length == 0)
{
res->number_empty++;
return;
}
- if (format_chars[--format_length] != 0)
- {
- res->number_unterminated++;
- return;
- }
/* Skip to first argument to check. */
while (arg_num + 1 < info->first_arg_num)