From 84cfd645c272a115e5858c8c5f985ec9ef9014a3 Mon Sep 17 00:00:00 2001 From: zhangjiarui3 Date: Mon, 13 Feb 2023 19:14:26 +0800 Subject: [PATCH] fixbug memory leak --- src/xdr_mem.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/xdr_mem.c b/src/xdr_mem.c index f5c35993f..f417b95ab 100644 --- a/src/xdr_mem.c +++ b/src/xdr_mem.c @@ -193,15 +193,17 @@ xdrmem_putbufs(XDR *xdrs, xdr_uio *uio, u_int flags) (unsigned long) XDR_GETPOS(xdrs)); } - if (!(--uio->uio_references)) { - if (uio->uio_release) { - uio->uio_release(uio, UIO_FLAG_NONE); - } else { - __warnx(TIRPC_DEBUG_FLAG_ERROR, - "%s() memory leak, unexpected or no release flags (%u)\n", - __func__, uio->uio_flags); - abort(); - } + if (uio->uio_references == 0){ + uio->uio_references = 1; + } + + if (uio->uio_release) { + uio->uio_release(uio, UIO_FLAG_NONE); + } else { + __warnx(TIRPC_DEBUG_FLAG_ERROR, + "%s() memory leak, unexpected or no release flags (%u)\n", + __func__, uio->uio_flags); + abort(); } return (TRUE);