Skip to content

Commit 6fa79bc

Browse files
author
Stefan Richter
committed
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>
1 parent 9489e9d commit 6fa79bc

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

tools/firewire/nosy-dump.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,8 @@ subaction_create(uint32_t *data, size_t length)
150150

151151
/* we put the ack in the subaction struct for easy access. */
152152
sa = malloc(sizeof *sa - sizeof sa->packet + length);
153+
if (!sa)
154+
exit(EXIT_FAILURE);
153155
sa->ack = data[length / 4 - 1];
154156
sa->length = length;
155157
memcpy(&sa->packet, data, length);
@@ -180,6 +182,8 @@ link_transaction_lookup(int request_node, int response_node, int tlabel)
180182
}
181183

182184
t = malloc(sizeof *t);
185+
if (!t)
186+
exit(EXIT_FAILURE);
183187
t->request_node = request_node;
184188
t->response_node = response_node;
185189
t->tlabel = tlabel;

0 commit comments

Comments
 (0)