~ubuntu-branches/ubuntu/precise/eglibc/precise-201308281639

« back to all changes in this revision

Viewing changes to stdio-common/vfprintf.c

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2012-02-08 01:58:09 UTC
  • mfrom: (1.5.3) (288.1.12 precise)
  • Revision ID: package-import@ubuntu.com-20120208015809-ulscst7uteq3e22z
Tags: 2.15~pre6-0ubuntu10
Merge from Debian (r5151, 2.13-26).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright (C) 1991-2008, 2009, 2010   Free Software Foundation, Inc.
 
1
/* Copyright (C) 1991-2008, 2009, 2010, 2011   Free Software Foundation, Inc.
2
2
   This file is part of the GNU C Library.
3
3
 
4
4
   The GNU C Library is free software; you can redistribute it and/or
53
53
      CHECK_FILE (S, -1);                                                     \
54
54
      if (S->_flags & _IO_NO_WRITES)                                          \
55
55
        {                                                                     \
 
56
          S->_flags |= _IO_ERR_SEEN;                                          \
56
57
          __set_errno (EBADF);                                                \
57
58
          return -1;                                                          \
58
59
        }                                                                     \
1660
1661
    /* Array with information about the needed arguments.  This has to
1661
1662
       be dynamically extensible.  */
1662
1663
    size_t nspecs = 0;
1663
 
    size_t nspecs_max = 32;     /* A more or less arbitrary start value.  */
1664
 
    struct printf_spec *specs
1665
 
      = alloca (nspecs_max * sizeof (struct printf_spec));
 
1664
    /* A more or less arbitrary start value.  */
 
1665
    size_t nspecs_size = 32 * sizeof (struct printf_spec);
 
1666
    struct printf_spec *specs = alloca (nspecs_size);
1666
1667
 
1667
1668
    /* The number of arguments the format string requests.  This will
1668
1669
       determine the size of the array needed to store the argument
1701
1702
 
1702
1703
    for (f = lead_str_end; *f != L_('\0'); f = specs[nspecs++].next_fmt)
1703
1704
      {
1704
 
        if (nspecs >= nspecs_max)
 
1705
        if (nspecs * sizeof (*specs) >= nspecs_size)
1705
1706
          {
1706
1707
            /* Extend the array of format specifiers.  */
1707
1708
            struct printf_spec *old = specs;
1708
 
            specs = extend_alloca (specs, nspecs_max, 2 * nspecs_max);
 
1709
            specs = extend_alloca (specs, nspecs_size, 2 * nspecs_size);
1709
1710
 
1710
1711
            /* Copy the old array's elements to the new space.  */
1711
 
            memmove (specs, old, nspecs * sizeof (struct printf_spec));
 
1712
            memmove (specs, old, nspecs * sizeof (*specs));
1712
1713
          }
1713
1714
 
1714
1715
        /* Parse the format specifier.  */