aboutsummaryrefslogtreecommitdiff
path: root/tools/firewire/nosy-dump.c
diff options
context:
space:
mode:
authorStefan Richter <stefanr@s5r6.in-berlin.de>2012-10-22 15:17:17 +0200
committerStefan Richter <stefanr@s5r6.in-berlin.de>2012-12-02 20:10:18 +0100
commit6fa79bcaecdbb0eb417afbc7fb0a8fa204308b62 (patch)
tree6be7fae45b04d900288c1ed70907fa97f2623cb3 /tools/firewire/nosy-dump.c
parent9489e9dcae718d5fde988e4a684a0f55b5f94d17 (diff)
tools/firewire: nosy-dump: check for allocation failure
Behavior of null pointer dereference is undefined in the C language. Portably implement the desired behavior. Reported-by: Yang Yeping <yangyeping_666@hotmail.com> Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Diffstat (limited to 'tools/firewire/nosy-dump.c')
-rw-r--r--tools/firewire/nosy-dump.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/tools/firewire/nosy-dump.c b/tools/firewire/nosy-dump.c
index f93b776370b6..3179c711bd65 100644
--- a/tools/firewire/nosy-dump.c
+++ b/tools/firewire/nosy-dump.c
@@ -150,6 +150,8 @@ subaction_create(uint32_t *data, size_t length)
/* we put the ack in the subaction struct for easy access. */
sa = malloc(sizeof *sa - sizeof sa->packet + length);
+ if (!sa)
+ exit(EXIT_FAILURE);
sa->ack = data[length / 4 - 1];
sa->length = length;
memcpy(&sa->packet, data, length);
@@ -180,6 +182,8 @@ link_transaction_lookup(int request_node, int response_node, int tlabel)
}
t = malloc(sizeof *t);
+ if (!t)
+ exit(EXIT_FAILURE);
t->request_node = request_node;
t->response_node = response_node;
t->tlabel = tlabel;