From b574c33a888ed7a9e439e074072b19e0309b3536 Mon Sep 17 00:00:00 2001 From: Markus Scherer Date: Wed, 9 Sep 2015 19:44:48 +0000 Subject: [PATCH] ICU-11873 fix memory leak in samples/layout/paragraph.cpp class Paragraph X-SVN-Rev: 37924 --- icu4c/source/samples/layout/paragraph.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/icu4c/source/samples/layout/paragraph.cpp b/icu4c/source/samples/layout/paragraph.cpp index 65d3e368423..9a92b5876d4 100644 --- a/icu4c/source/samples/layout/paragraph.cpp +++ b/icu4c/source/samples/layout/paragraph.cpp @@ -1,7 +1,7 @@ /* ******************************************************************************* * - * Copyright (C) 1999-2007, International Business Machines + * Copyright (C) 1999-2015, International Business Machines * Corporation and others. All Rights Reserved. * ******************************************************************************* @@ -115,6 +115,7 @@ Paragraph::Paragraph(const LEUnicode chars[], int32_t charCount, const FontRuns paragraphLayout = new ParagraphLayout(pStart, pEnd - pStart, &fr, NULL, NULL, locales, fParagraphLevel, FALSE, status); if (LE_FAILURE(status)) { + delete paragraphLayout; break; // return? something else? } @@ -163,8 +164,12 @@ Paragraph::~Paragraph() delete /*(LineInfo *)*/ fLines[line]; } + for (le_int32 paragraph = 0; paragraph < fParagraphCount; paragraph += 1) { + delete fParagraphLayout[paragraph]; + } + LE_DELETE_ARRAY(fLines); - delete fParagraphLayout; + LE_DELETE_ARRAY(fParagraphLayout); LE_DELETE_ARRAY(fChars); } -- 2.40.0