Skip to content

Commit e9dac22

Browse files
authored
Merge pull request #446 from geoffw0/minor-corrections
CPP: Minor corrections to examples
2 parents 0caf0f1 + e645166 commit e9dac22

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
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
}

cpp/ql/src/Critical/OverflowCalculated.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
void f(char* string) {
2-
// wrong: allocates space for characters, put not zero terminator
2+
// wrong: allocates space for characters, but not zero terminator
33
char* buf = malloc(strlen(string));
44
strcpy(buf, string);
55

0 commit comments

Comments
 (0)