]> git.meshlink.io Git - utcp/blobdiff - utcp.c
Fix a memory leak on invalid invocation of utcp_init().
[utcp] / utcp.c
diff --git a/utcp.c b/utcp.c
index 2b2db972163ceb2427b817f2bc70bc69d84889df..ad19982ba95afdb613eb780e6ac8d8eff6511ee3 100644 (file)
--- a/utcp.c
+++ b/utcp.c
@@ -1309,15 +1309,15 @@ bool utcp_is_active(struct utcp *utcp) {
 }
 
 struct utcp *utcp_init(utcp_accept_t accept, utcp_pre_accept_t pre_accept, utcp_send_t send, void *priv) {
-       struct utcp *utcp = calloc(1, sizeof *utcp);
-       if(!utcp)
-               return NULL;
-
        if(!send) {
                errno = EFAULT;
                return NULL;
        }
 
+       struct utcp *utcp = calloc(1, sizeof *utcp);
+       if(!utcp)
+               return NULL;
+
        utcp->accept = accept;
        utcp->pre_accept = pre_accept;
        utcp->send = send;