From fdb25f2eae20092f4d70d471848de31c7f7843ce Mon Sep 17 00:00:00 2001 From: Alina Lenk Date: Mon, 29 Apr 2024 23:39:01 +0200 Subject: [PATCH] json protocol: free json object when discarding info packet See RM #511 Signed-off-by: Alina Lenk --- common/generate_packets.py | 2 +- common/networking/packets.h | 3 +++ common/networking/packets_json.h | 8 ++++++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/common/generate_packets.py b/common/generate_packets.py index 1e2e9cfd5f..1d7ade7eba 100755 --- a/common/generate_packets.py +++ b/common/generate_packets.py @@ -2898,7 +2898,7 @@ if (different == 0) {{ {log_discard}\ {stats_discard}\ {before_return}\ - return 0; + SEND_PACKET_DISCARD(); }} """ else: diff --git a/common/networking/packets.h b/common/networking/packets.h index 5de13f12fc..84c22d23f2 100644 --- a/common/networking/packets.h +++ b/common/networking/packets.h @@ -144,6 +144,9 @@ void packets_deinit(void); return send_packet_data(pc, buffer, size, packet_type); \ } +#define SEND_PACKET_DISCARD() \ + return 0 + #define RECEIVE_PACKET_START(packet_type, result) \ struct data_in din; \ struct packet_type packet_buf, *result = &packet_buf; \ diff --git a/common/networking/packets_json.h b/common/networking/packets_json.h index 677b2ae9eb..19e8bcae38 100644 --- a/common/networking/packets_json.h +++ b/common/networking/packets_json.h @@ -67,6 +67,14 @@ void *get_packet_from_connection_json(struct connection *pc, return send_packet_data(pc, buffer, size, packet_type); \ } +#define SEND_PACKET_DISCARD() \ + { \ + if (pc->json_mode) { \ + json_decref(dout.json); \ + } \ + return 0; \ + } + #define RECEIVE_PACKET_START(packet_type, result) \ struct packet_type packet_buf, *result = &packet_buf; \ struct data_in din; \ -- 2.34.1