mirror of
https://github.com/github/codeql.git
synced 2025-12-26 21:56:39 +01:00
CPP: Make InconsistentNullnessTest.cpp example plausible.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user