Skip to content

Commit e645166

Browse files
committed
CPP: Make InconsistentNullnessTest.cpp example plausible.
1 parent d5c6f4f commit e645166

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
void* f() {
2-
block = malloc(BLOCK_SIZE);
2+
block = (MyBlock *)malloc(sizeof(MyBlock));
33
if (block) { //correct: block is checked for nullness here
44
block->id = NORMAL_BLOCK_ID;
55
}
66
//...
77
/* make sure data-portion is null-terminated */
8-
block[BLOCK_SIZE - 1] = '\0'; //wrong: block not checked for nullness here
8+
block->data[BLOCK_SIZE - 1] = '\0'; //wrong: block not checked for nullness here
99
return block;
1010
}

0 commit comments

Comments
 (0)