Merge pull request #1535 from geoffw0/nospacezero

CPP: Fix false positives from NoSpaceForZeroTerminator.ql
This commit is contained in:
Jonas Jensen
2019-07-04 22:36:04 +02:00
committed by GitHub
3 changed files with 22 additions and 0 deletions

View File

@@ -63,3 +63,15 @@ void good3(char *str) {
char *buffer = malloc((strlen(str) + 1) * sizeof(char));
free(buffer);
}
void *memcpy(void *s1, const void *s2, size_t n);
void good4(char *str) {
// GOOD -- allocating a non zero-terminated string
int len = strlen(str);
char *buffer = malloc(len);
memcpy(buffer, str, len);
free(buffer);
}