Skip to content

Commit ed442fe

Browse files
maurizio-lombardiigaw
authored andcommitted
linux: avoid potential null pointer dereference
if the "result" pointer is null because of a memory allocation failure, do not dereference it and do not free the old pointer. Signed-off-by: Maurizio Lombardi <[email protected]>
1 parent 3120b49 commit ed442fe

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/nvme/util.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1144,7 +1144,7 @@ void *__nvme_realloc(void *p, size_t len)
11441144

11451145
void *result = __nvme_alloc(len);
11461146

1147-
if (p) {
1147+
if (p && result) {
11481148
memcpy(result, p, min(old_len, len));
11491149
free(p);
11501150
}

0 commit comments

Comments
 (0)