layer2_tx: Fixed stack-use-after-return
This commit is contained in:
parent
725a0ffd21
commit
041255e15f
|
@ -59,13 +59,20 @@ result_t layer2_tx_fill_packet_queue(layer2_tx_t *ctx)
|
||||||
// a packet is available -> move it to the queue
|
// a packet is available -> move it to the queue
|
||||||
header.tx_seq_nr = ctx->next_seq_nr;
|
header.tx_seq_nr = ctx->next_seq_nr;
|
||||||
|
|
||||||
uint8_t packetbuf[2048];
|
uint8_t *packetbuf = malloc(2048);
|
||||||
|
if(!packetbuf) {
|
||||||
|
LOG(LVL_ERR, "malloc failed.");
|
||||||
|
return ERR_NO_MEM;
|
||||||
|
}
|
||||||
|
|
||||||
ret = read(ctx->tun_fd, packetbuf, sizeof(packetbuf));
|
ret = read(ctx->tun_fd, packetbuf, sizeof(packetbuf));
|
||||||
if(ret < 0) {
|
if(ret < 0) {
|
||||||
LOG(LVL_ERR, "read: %s", strerror(errno));
|
LOG(LVL_ERR, "read: %s", strerror(errno));
|
||||||
|
free(packetbuf);
|
||||||
return ERR_SYSCALL;
|
return ERR_SYSCALL;
|
||||||
} else if(ret == 0) {
|
} else if(ret == 0) {
|
||||||
// no more data
|
// no more data
|
||||||
|
free(packetbuf);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue