]> git.proxmox.com Git - mirror_frr.git/commitdiff
lib: clear caller's pointer when freeing context struct
authorMark Stapp <mjs.ietf@gmail.com>
Mon, 9 Aug 2021 15:55:15 +0000 (11:55 -0400)
committerMark Stapp <mjs.ietf@gmail.com>
Thu, 19 Aug 2021 17:31:33 +0000 (13:31 -0400)
The zeromq lib wrapper uses an internal context struct to help
interact with the libfrr event mechanism. When freeing that
context struct, ensure the caller's pointer is also cleared.

Signed-off-by: Mark Stapp <mjs.ietf@gmail.com>
lib/frr_zmq.c

index ea9c828f7c00af80b564912fefa6a223ca7acca5..994fe656fdd278201675b710f079adbca1802934 100644 (file)
@@ -92,7 +92,8 @@ static int frrzmq_read_msg(struct thread *t)
                                                    ZMQ_POLLOUT);
                                cb->read.thread = NULL;
                                if (cb->write.cancelled && !cb->write.thread)
-                                       XFREE(MTYPE_ZEROMQ_CB, cb);
+                                       XFREE(MTYPE_ZEROMQ_CB, *cbp);
+
                                return 0;
                        }
                        continue;
@@ -120,7 +121,8 @@ static int frrzmq_read_msg(struct thread *t)
                                                    ZMQ_POLLOUT);
                                cb->read.thread = NULL;
                                if (cb->write.cancelled && !cb->write.thread)
-                                       XFREE(MTYPE_ZEROMQ_CB, cb);
+                                       XFREE(MTYPE_ZEROMQ_CB, *cbp);
+
                                return 0;
                        }
 
@@ -239,7 +241,8 @@ static int frrzmq_write_msg(struct thread *t)
                                frrzmq_check_events(cbp, &cb->read, ZMQ_POLLIN);
                                cb->write.thread = NULL;
                                if (cb->read.cancelled && !cb->read.thread)
-                                       XFREE(MTYPE_ZEROMQ_CB, cb);
+                                       XFREE(MTYPE_ZEROMQ_CB, *cbp);
+
                                return 0;
                        }
                        continue;