From e645166feecae2ace3bcd50c513469e40fc6bbf4 Mon Sep 17 00:00:00 2001 From: Geoffrey White <40627776+geoffw0@users.noreply.github.com> Date: Fri, 9 Nov 2018 11:36:39 +0000 Subject: [PATCH] CPP: Make InconsistentNullnessTest.cpp example plausible. --- cpp/ql/src/Critical/InconsistentNullnessTesting.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cpp/ql/src/Critical/InconsistentNullnessTesting.cpp b/cpp/ql/src/Critical/InconsistentNullnessTesting.cpp index b071e79ecdb..d7d60b46806 100644 --- a/cpp/ql/src/Critical/InconsistentNullnessTesting.cpp +++ b/cpp/ql/src/Critical/InconsistentNullnessTesting.cpp @@ -1,10 +1,10 @@ void* f() { - block = malloc(BLOCK_SIZE); + block = (MyBlock *)malloc(sizeof(MyBlock)); if (block) { //correct: block is checked for nullness here block->id = NORMAL_BLOCK_ID; } //... /* make sure data-portion is null-terminated */ - block[BLOCK_SIZE - 1] = '\0'; //wrong: block not checked for nullness here + block->data[BLOCK_SIZE - 1] = '\0'; //wrong: block not checked for nullness here return block; }