From d178f871644d97853be0f89d05a8fc5649e5d620 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Thu, 28 Apr 2011 07:46:40 -0400 Subject: [PATCH] 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). --- src/ChangeLog | 5 +++++ src/doprnt.c | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) 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; } } -- 2.39.2