From 2aec706328ce62c4530cb0badb81106834ce6b55 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Fri, 30 Apr 2021 11:19:27 +0200 Subject: [PATCH] fix: memory leak when reconnecting to device, reuse old struct --- client/src/comms.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/client/src/comms.c b/client/src/comms.c index 4e624aa86..5101b019e 100644 --- a/client/src/comms.c +++ b/client/src/comms.c @@ -592,7 +592,9 @@ bool OpenProxmark(pm3_device **dev, char *port, bool wait_for_port, int timeout, session.pm3_present = true; // TODO support for multiple devices fflush(stdout); - *dev = malloc(sizeof(pm3_device)); + if (*dev == NULL) { + *dev = calloc(sizeof(pm3_device), sizeof(uint8_t)); + } (*dev)->conn = &conn; // TODO conn shouldn't be global return true; }