Author: manolo Date: 2010-04-13 10:58:30 -0700 (Tue, 13 Apr 2010) New Revision: 7494 Log: gl_draw.cxx (Mac-specific): fixed use of fl_measure with non null-terminated string.
Modified: branches/branch-1.3/src/gl_draw.cxx Modified: branches/branch-1.3/src/gl_draw.cxx =================================================================== --- branches/branch-1.3/src/gl_draw.cxx 2010-04-13 17:44:52 UTC (rev 7493) +++ branches/branch-1.3/src/gl_draw.cxx 2010-04-13 17:58:30 UTC (rev 7494) @@ -478,8 +478,12 @@ 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 @@ 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; } _______________________________________________ fltk-commit mailing list [email protected] http://lists.easysw.com/mailman/listinfo/fltk-commit
