From 0458224743337acef025f53da01beb46eacd4493 Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Mon, 18 Apr 2016 12:31:49 +0200 Subject: Avoid nullptr deref in Q_ASSERTS Found by Coverity, CIDs: [159014-159383]. Indeed, Q_ASSERTS can go into the block controlled by the corresponding if-statements, otherwise - why 'if' at all? Change-Id: Ibc99cd48b97287ec132e082d14f3c39350d547f9 Reviewed-by: Lars Knoll --- src/gui/opengl/qopenglfunctions_3_2_core.cpp | 55 +++++++++++++++++----------- 1 file changed, 33 insertions(+), 22 deletions(-) (limited to 'src/gui/opengl/qopenglfunctions_3_2_core.cpp') diff --git a/src/gui/opengl/qopenglfunctions_3_2_core.cpp b/src/gui/opengl/qopenglfunctions_3_2_core.cpp index 177dc9e25d..02c0c78b01 100644 --- a/src/gui/opengl/qopenglfunctions_3_2_core.cpp +++ b/src/gui/opengl/qopenglfunctions_3_2_core.cpp @@ -83,39 +83,50 @@ QOpenGLFunctions_3_2_Core::QOpenGLFunctions_3_2_Core() QOpenGLFunctions_3_2_Core::~QOpenGLFunctions_3_2_Core() { - if (d_1_0_Core) + if (d_1_0_Core) { d_1_0_Core->refs.deref(); - Q_ASSERT(d_1_0_Core->refs.load()); - if (d_1_1_Core) + Q_ASSERT(d_1_0_Core->refs.load()); + } + if (d_1_1_Core) { d_1_1_Core->refs.deref(); - Q_ASSERT(d_1_1_Core->refs.load()); - if (d_1_2_Core) + Q_ASSERT(d_1_1_Core->refs.load()); + } + if (d_1_2_Core) { d_1_2_Core->refs.deref(); - Q_ASSERT(d_1_2_Core->refs.load()); - if (d_1_3_Core) + Q_ASSERT(d_1_2_Core->refs.load()); + } + if (d_1_3_Core) { d_1_3_Core->refs.deref(); - Q_ASSERT(d_1_3_Core->refs.load()); - if (d_1_4_Core) + Q_ASSERT(d_1_3_Core->refs.load()); + } + if (d_1_4_Core) { d_1_4_Core->refs.deref(); - Q_ASSERT(d_1_4_Core->refs.load()); - if (d_1_5_Core) + Q_ASSERT(d_1_4_Core->refs.load()); + } + if (d_1_5_Core) { d_1_5_Core->refs.deref(); - Q_ASSERT(d_1_5_Core->refs.load()); - if (d_2_0_Core) + Q_ASSERT(d_1_5_Core->refs.load()); + } + if (d_2_0_Core) { d_2_0_Core->refs.deref(); - Q_ASSERT(d_2_0_Core->refs.load()); - if (d_2_1_Core) + Q_ASSERT(d_2_0_Core->refs.load()); + } + if (d_2_1_Core) { d_2_1_Core->refs.deref(); - Q_ASSERT(d_2_1_Core->refs.load()); - if (d_3_0_Core) + Q_ASSERT(d_2_1_Core->refs.load()); + } + if (d_3_0_Core) { d_3_0_Core->refs.deref(); - Q_ASSERT(d_3_0_Core->refs.load()); - if (d_3_1_Core) + Q_ASSERT(d_3_0_Core->refs.load()); + } + if (d_3_1_Core) { d_3_1_Core->refs.deref(); - Q_ASSERT(d_3_1_Core->refs.load()); - if (d_3_2_Core) + Q_ASSERT(d_3_1_Core->refs.load()); + } + if (d_3_2_Core) { d_3_2_Core->refs.deref(); - Q_ASSERT(d_3_2_Core->refs.load()); + Q_ASSERT(d_3_2_Core->refs.load()); + } } bool QOpenGLFunctions_3_2_Core::initializeOpenGLFunctions() -- cgit v1.2.3