Skip to content

Commit 84aea8e

Browse files
committed
[CID 16896] Fix memory leak when compacting paragraphs.
Coverity-ID: 16986
1 parent 1a7d469 commit 84aea8e

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

engine/src/cdata.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,10 +226,12 @@ MCParagraph *MCCdata::getparagraphs()
226226
MCParagraph *tpgptr = new (nothrow) MCParagraph;
227227
tpgptr->appendto(paragraphs);
228228
uint2 l = strlen(eptr) + 1;
229-
char *sptr = new (nothrow) char[l];
230-
memcpy(sptr, eptr, l);
229+
/* UNCHECKED */ MCAutoPointer<char_t[]> sptr =
230+
new (nothrow) char_t[l];
231+
memcpy(sptr.Get(), eptr, l);
231232
MCAutoStringRef t_string;
232-
/* UNCHECKED */ MCStringCreateWithNativeChars((const char_t*)sptr, l, &t_string);
233+
/* UNCHECKED */ MCStringCreateWithNativeChars(sptr.Get(), l,
234+
&t_string);
233235
tpgptr->settext(*t_string);
234236
eptr = NULL;
235237
}

0 commit comments

Comments
 (0)