From: Eli Zaretskii Date: Thu, 28 Apr 2011 11:46:40 +0000 (-0400) Subject: Fix return value from doprnt when message is truncated at non-ASCII character. X-Git-Tag: emacs-pretest-24.0.90~104^2~275^2~190 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=d178f871644d97853be0f89d05a8fc5649e5d620;p=emacs.git Fix return value from doprnt when message is truncated at non-ASCII character. src/doprnt.c (doprnt): Don't return value smaller than the buffer size if the message was truncated. (Bug#8545). --- diff --git a/src/ChangeLog b/src/ChangeLog index 91777751853..107d6f0073a 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2011-04-28 Eli Zaretskii + + * doprnt.c (doprnt): Don't return value smaller than the buffer + size if the message was truncated. (Bug#8545). + 2011-04-28 Juanma Barranquero * w32fns.c (Fx_change_window_property, Fx_delete_window_property) diff --git a/src/doprnt.c b/src/doprnt.c index a6becc7454f..63dba9f5850 100644 --- a/src/doprnt.c +++ b/src/doprnt.c @@ -403,7 +403,9 @@ doprnt (char *buffer, register size_t bufsize, const char *format, while (fmt < format_end && --bufsize > 0 && !CHAR_HEAD_P (*fmt)); if (!CHAR_HEAD_P (*fmt)) { - bufptr = save_bufptr; + /* Truncate, but return value that will signal to caller + that the buffer was too small. */ + *save_bufptr = 0; break; } }