]> git.meshlink.io Git - utcp/commitdiff
Keep a copy of the old receive callback before calling reset_connection().
authorGuus Sliepen <guus@sliepen.org>
Wed, 27 Feb 2019 19:05:00 +0000 (20:05 +0100)
committerGuus Sliepen <guus@sliepen.org>
Wed, 27 Feb 2019 19:05:00 +0000 (20:05 +0100)
The latter function clears the receive callback, so make a copy before
calling trying to call the receive callback for the final time.

utcp.c

diff --git a/utcp.c b/utcp.c
index d09b9e7d526e80c4ce39590c19c718904fe32590..9fb68aecd323dd2019171df1b86199c37af71544 100644 (file)
--- a/utcp.c
+++ b/utcp.c
@@ -1664,11 +1664,13 @@ void utcp_abort_all_connections(struct utcp *utcp) {
                        continue;
                }
 
+               utcp_recv_t old_recv = c->recv;
+
                reset_connection(c);
 
-               if(c->recv) {
+               if(old_recv) {
                        errno = 0;
-                       c->recv(c, NULL, 0);
+                       old_recv(c, NULL, 0);
                }
        }