From 3c7af7b61aea67731c469405cbae0cbe7c2c7d54 Mon Sep 17 00:00:00 2001 From: Michal Bloch Date: Mon, 7 Dec 2020 22:16:07 +0100 Subject: Fix null dereferences Change-Id: Id23b9aaad60752f797783f9ccc6f9bbfa9357941 Signed-off-by: Michal Bloch (cherry picked from commit a9a8f5e3955f55e03a05878a381257085dc02951) --- src/crash-stack/proc.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/crash-stack/proc.c b/src/crash-stack/proc.c index fd346c6..3c9f44a 100644 --- a/src/crash-stack/proc.c +++ b/src/crash-stack/proc.c @@ -293,6 +293,8 @@ char *get_thread_states(const int *tids, int n) { int i; char *res = calloc(1, n); + if (!res) + return NULL; for (i = 0; i < n; ++i) { int state = proc_state(tids[i]); @@ -382,6 +384,9 @@ static int copy_memory_process_vm_readv(int pid, remote_iov = malloc(sizeof(struct iovec)*n_frames); frame_bytes = malloc(sizeof(ssize_t)*n_frames); + if (!local_iov || !remote_iov || !frame_bytes) + goto process_vm_readv_end; + for (i = 0; i < n_frames; ++i) { local_iov[i].iov_base = frames[i]->data; local_iov[i].iov_len = frames[i]->length; -- cgit v1.2.3