Merge from emacs-24; up to 2012-12-26T16:22:18Z!michael.albinus@gmx.de
[bpt/emacs.git] / src / doprnt.c
index 6c43d00..087256c 100644 (file)
@@ -38,7 +38,7 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
      could include embedded null characters.
 
    . It signals an error if the length of the formatted string is about to
-     overflow MOST_POSITIVE_FIXNUM, to avoid producing strings longer than what
+     overflow ptrdiff_t or size_t, to avoid producing strings longer than what
      Emacs can handle.
 
    OTOH, this function supports only a small subset of the standard C formatted
@@ -361,7 +361,7 @@ doprnt (char *buffer, ptrdiff_t bufsize, const char *format,
 
              /* Copy string into final output, truncating if no room.  */
            doit:
-             eassert (0 <= tem);
+             eassert (tem >= 0);
              /* Coming here means STRING contains ASCII only.  */
              if (STRING_BYTES_BOUND < tem)
                error ("Format width or precision too large");
@@ -521,7 +521,10 @@ evxprintf (char **buf, ptrdiff_t *bufsize,
       if (nbytes < *bufsize - 1)
        return nbytes;
       if (*buf != nonheapbuf)
-       xfree (*buf);
+       {
+         xfree (*buf);
+         *buf = NULL;
+       }
       *buf = xpalloc (NULL, bufsize, 1, bufsize_max, 1);
     }
 }