Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6fa79bca authored by Stefan Richter's avatar Stefan Richter
Browse files

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: default avatarYang Yeping <yangyeping_666@hotmail.com>
Signed-off-by: default avatarStefan Richter <stefanr@s5r6.in-berlin.de>
parent 9489e9dc
Loading
Loading
Loading
Loading
+4 −0
Original line number Original line Diff line number Diff line
@@ -150,6 +150,8 @@ subaction_create(uint32_t *data, size_t length)


	/* we put the ack in the subaction struct for easy access. */
	/* we put the ack in the subaction struct for easy access. */
	sa = malloc(sizeof *sa - sizeof sa->packet + length);
	sa = malloc(sizeof *sa - sizeof sa->packet + length);
	if (!sa)
		exit(EXIT_FAILURE);
	sa->ack = data[length / 4 - 1];
	sa->ack = data[length / 4 - 1];
	sa->length = length;
	sa->length = length;
	memcpy(&sa->packet, data, 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);
	t = malloc(sizeof *t);
	if (!t)
		exit(EXIT_FAILURE);
	t->request_node = request_node;
	t->request_node = request_node;
	t->response_node = response_node;
	t->response_node = response_node;
	t->tlabel = tlabel;
	t->tlabel = tlabel;