From: João Abecasis Date: Mon, 2 May 2011 11:46:40 +0000 (+0200) Subject: Don't realloc user-provided buffer X-Git-Tag: qt-v5.0.0-alpha1~4322^2~19 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e6e6e4c1695822776957af66413450aaccc0ff65;p=profile%2Fivi%2Fqtbase.git Don't realloc user-provided buffer When QTextBoundaryFinder doesn't own the buffer, don't realloc it and get a new one instead. Reviewed-by: Ritt Konstantin (cherry picked from commit 320f172c851a4720299297c8b3b757eb1202c568) --- diff --git a/src/corelib/tools/qtextboundaryfinder.cpp b/src/corelib/tools/qtextboundaryfinder.cpp index 34bc406..47319d4 100644 --- a/src/corelib/tools/qtextboundaryfinder.cpp +++ b/src/corelib/tools/qtextboundaryfinder.cpp @@ -199,11 +199,11 @@ QTextBoundaryFinder &QTextBoundaryFinder::operator=(const QTextBoundaryFinder &o chars = other.chars; length = other.length; pos = other.pos; - freePrivate = true; QTextBoundaryFinderPrivate *newD = (QTextBoundaryFinderPrivate *) - realloc(d, length*sizeof(HB_CharAttributes)); + realloc(freePrivate ? d : 0, length*sizeof(HB_CharAttributes)); Q_CHECK_PTR(newD); + freePrivate = true; d = newD; memcpy(d, other.d, length*sizeof(HB_CharAttributes));