From da09ccce7ac9eca4e19f409215cc2897866e0a50 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Tue, 5 Apr 2011 13:22:53 -0700 Subject: [PATCH] * fns.c (Fstring_to_unibyte): Don't rely on undefined behavior by passing a long int to a printf format expecting an int. --- src/ChangeLog | 3 +++ src/fns.c | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/ChangeLog b/src/ChangeLog index 185d611ea6e..fd864a460f4 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -2,6 +2,9 @@ Fix more problems found by GCC 4.6.0's static checks. + * fns.c (Fstring_to_unibyte): Don't rely on undefined behavior + by passing a long int to a printf format expecting an int. + * lisp.h (message, message_nolog, doprint, error, verror, fatal): Mark as printf-like functions. diff --git a/src/fns.c b/src/fns.c index c45d9e31ef2..ca18dbfc100 100644 --- a/src/fns.c +++ b/src/fns.c @@ -1076,7 +1076,10 @@ an error is signaled. */) EMACS_INT converted = str_to_unibyte (SDATA (string), str, chars, 0); if (converted < chars) - error ("Can't convert the %dth character to unibyte", converted); + { + long lconverted = converted; + error ("Can't convert the %ldth character to unibyte", lconverted); + } string = make_unibyte_string ((char *) str, chars); xfree (str); } -- 2.39.2