summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ChangeLog6
-rw-r--r--src/nsfont.m3
2 files changed, 8 insertions, 1 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 1956d602e6a..5956eea1c51 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,9 @@
+2012-08-18 Alp Aker <alp.tekin.aker@gmail.com>
+
+ * nsfont.m (ns_ascii_average_width): Ensure the string
+ ascii_printable is initialized with a null-terminated character
+ array. Otherwise, it can contain undesired extra characters.
+
2012-08-18 Paul Eggert <eggert@cs.ucla.edu>
port new setting code to Sun C 5.8 2005/10/13
diff --git a/src/nsfont.m b/src/nsfont.m
index 1f8d28cd238..412a6777c64 100644
--- a/src/nsfont.m
+++ b/src/nsfont.m
@@ -270,10 +270,11 @@ ns_ascii_average_width (NSFont *sfont)
if (!ascii_printable)
{
- char chars[95];
+ char chars[96];
int ch;
for (ch = 0; ch < 95; ch++)
chars[ch] = ' ' + ch;
+ chars[95] = '\0';
ascii_printable = [[NSString alloc] initWithFormat: @"%s", chars];
}