From 96c392763edb530b305ebc7517281d28b1862b29 Mon Sep 17 00:00:00 2001 From: Manolo Gouy <Manolo> Date: Tue, 13 Apr 2010 17:58:30 +0000 Subject: [PATCH] gl_draw.cxx (Mac-specific): fixed use of fl_measure with non null-terminated string. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@7494 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- src/gl_draw.cxx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/gl_draw.cxx b/src/gl_draw.cxx index 52222b4fc..e9c34c12c 100644 --- a/src/gl_draw.cxx +++ b/src/gl_draw.cxx @@ -478,8 +478,12 @@ int gl_texture_fifo::compute_texture(const char* str, int n) current = (current + 1) % size_; if (current > last) last = current; //write str to a bitmap just big enough + if ( fifo[current].utf8 ) free(fifo[current].utf8); + fifo[current].utf8 = (char *)malloc(n + 1); + memcpy(fifo[current].utf8, str, n); + fifo[current].utf8[n] = 0; fifo[current].width = 0, fifo[current].height = 0; - fl_measure(str, fifo[current].width, fifo[current].height, 0); + fl_measure(fifo[current].utf8, fifo[current].width, fifo[current].height, 0); CGColorSpaceRef lut = CGColorSpaceCreateDeviceRGB(); void *base = calloc(4*fifo[current].width, fifo[current].height); if (base == NULL) return -1; @@ -500,10 +504,6 @@ int gl_texture_fifo::compute_texture(const char* str, int n) CGContextRelease(fl_gc); fl_gc = NULL; free(base); - if ( fifo[current].utf8 ) free(fifo[current].utf8); - fifo[current].utf8 = (char *)malloc(n + 1); - memcpy(fifo[current].utf8, str, n); - fifo[current].utf8[n] = 0; fifo[current].fdesc = gl_fontsize; return current; } -- GitLab