Remove last_cnx access on invalid packet receive and proper free

This commit is contained in:
Jop Zitman 2025-03-21 21:24:20 +08:00
parent ca7e49d601
commit 7ad057e8ea
3 changed files with 7 additions and 1 deletions

View file

@ -211,11 +211,13 @@ slipstream_server_stream_ctx_t* slipstream_server_create_stream_ctx(slipstream_s
int sock_fd = socket(AF_INET, SOCK_STREAM, 0);
if (sock_fd < 0) {
perror("socket() failed");
free(stream_ctx);
return NULL;
}
if (connect(sock_fd, (struct sockaddr*)&server_ctx->upstream_addr, sizeof(server_ctx->upstream_addr)) < 0) {
perror("connect() failed");
free(stream_ctx);
return NULL;
}

View file

@ -1,4 +1,4 @@
#include "../include/slipstream_server_cc.h"
#include "slipstream_server_cc.h"
#include <stdlib.h>

View file

@ -153,6 +153,10 @@ int slipstream_packet_loop_(picoquic_network_thread_ctx_t* thread_ctx, picoquic_
if (ret < 0) {
return ret;
}
if (last_cnx == NULL) {
DBG_PRINTF("last_cnx null in recv", NULL);
continue;
}
slot->cnx = last_cnx;
slot->path_id = last_path_id;
nb_packet_received++;