Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit c4a9234

Browse files
committed
[[ Bug 16294 ]] Fix memory leak in MCCustomPrinter.
1 parent 1527e4d commit c4a9234

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

engine/src/customprinter.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,6 +1026,7 @@ static bool dotextmark_callback(void *p_context, const MCTextLayoutSpan *p_span)
10261026
MCAutoStringRef t_string;
10271027
// SN-2014-06-17 [[ Bug 12595 ]] Not properly causing the bug, but it never hurts to get to use the right encoding
10281028
MCStringCreateWithBytes((byte_t*)p_span->chars, p_span->char_count * 2, kMCStringEncodingUTF16, false, &t_string);
1029+
10291030
byte_t *t_bytes;
10301031
uindex_t t_byte_count;
10311032
/* UNCHECKED */ MCStringConvertToBytes(*t_string, kMCStringEncodingUTF8, false, t_bytes, t_byte_count);
@@ -1034,7 +1035,10 @@ static bool dotextmark_callback(void *p_context, const MCTextLayoutSpan *p_span)
10341035
uint32_t *t_clusters;
10351036
t_clusters = nil;
10361037
if (!MCMemoryNewArray(t_byte_count, t_clusters))
1038+
{
1039+
MCMemoryDeleteArray(t_bytes);
10371040
return false;
1041+
}
10381042

10391043
// Now loop through and build up the cluster array. Notice we keep track of
10401044
// UTF-16 codepoint index by taking note of leading UTF-8 bytes.
@@ -1099,6 +1103,7 @@ static bool dotextmark_callback(void *p_context, const MCTextLayoutSpan *p_span)
10991103
t_success = context -> device -> DrawText((const MCCustomPrinterGlyph *)p_span -> glyphs, p_span -> glyph_count, (const char *)t_bytes, t_byte_count, t_clusters, t_font, context -> paint, context -> transform, context -> clip);
11001104

11011105
MCMemoryDeleteArray(t_clusters);
1106+
MCMemoryDeleteArray(t_bytes);
11021107

11031108
return t_success;
11041109
}

0 commit comments

Comments
 (0)