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)
This commit is contained in:
João Abecasis 2011-05-02 13:46:40 +02:00 committed by Olivier Goffart
parent bc88f528dc
commit e6e6e4c169

View File

@ -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));