summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarc Mutz <[email protected]>2025-07-01 14:39:42 +0200
committerMarc Mutz <[email protected]>2025-07-01 19:50:43 +0200
commitfa225324cdb2867c9eb45b3c610651f9871c911a (patch)
tree1f60e4ef337559f46e483dd5e7fd5fa68d0214fd /src
parent3aa82a0ecf9c7a5cb2a1c7f64261d9b8582645ac (diff)
QClipData: fix incorrect realloc() useHEADdev
The realloc() calls unconditionally overwrote m_spans with the result of realloc() before checking whether realloc() succeeded. This way, they leaked memory if realloc() did fail (they lost their handle on the old, still-existing memory block). Fix by piping the realloc() result through q_check_ptr(), which inserts Q_CHECK_PTR(), so we don't need a temporary variable here. As a drive-by, replace C-style cast with static_cast and fix spacing around binary operators. Amends the start of the public history. Pick-to: 6.10 6.9 6.8 6.5 Change-Id: Ia77a246bf6eec4e29ea6a01f999d3f4a43e0ee1c Reviewed-by: Thiago Macieira <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/gui/painting/qpaintengine_raster_p.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/gui/painting/qpaintengine_raster_p.h b/src/gui/painting/qpaintengine_raster_p.h
index d436afc5c77..1a60afbdd8e 100644
--- a/src/gui/painting/qpaintengine_raster_p.h
+++ b/src/gui/painting/qpaintengine_raster_p.h
@@ -361,7 +361,7 @@ inline void QClipData::appendSpan(int x, int length, int y, int coverage)
if (count == allocated) {
allocated *= 2;
- m_spans = (QT_FT_Span *)realloc(m_spans, allocated*sizeof(QT_FT_Span));
+ m_spans = static_cast<QT_FT_Span*>(q_check_ptr(realloc(m_spans, allocated * sizeof(QT_FT_Span))));
}
m_spans[count].x = x;
m_spans[count].len = length;
@@ -378,7 +378,7 @@ inline void QClipData::appendSpans(const QT_FT_Span *s, int num)
do {
allocated *= 2;
} while (count + num > allocated);
- m_spans = (QT_FT_Span *)realloc(m_spans, allocated*sizeof(QT_FT_Span));
+ m_spans = static_cast<QT_FT_Span*>(q_check_ptr(realloc(m_spans, allocated * sizeof(QT_FT_Span))));
}
memcpy(m_spans+count, s, num*sizeof(QT_FT_Span));
count += num;