Skip to content

Commit

Permalink
linux: avoid potential null pointer dereference
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
maurizio-lombardi authored and igaw committed Jun 25, 2024
1 parent 3120b49 commit ed442fe
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/nvme/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -1144,7 +1144,7 @@ void *__nvme_realloc(void *p, size_t len)

void *result = __nvme_alloc(len);

if (p) {
if (p && result) {
memcpy(result, p, min(old_len, len));
free(p);
}
Expand Down

0 comments on commit ed442fe

Please sign in to comment.