[PATCH] [nfs/nfs-utils/libtirpc] getnetconfig.c: free linep to avoid memory leakage

Subsystems: the rest · Maintainer: Linus Torvalds

STALE714d

2 messages, 2 authors, 2024-11-11 · open the first message on its own page

[PATCH] [nfs/nfs-utils/libtirpc] getnetconfig.c: free linep to avoid memory leakage

From: Zhi Li <hidden>
Date: 2023-02-01 10:58:16

Signed-off-by: Zhi Li <redacted>
---
 src/getnetconfig.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/src/getnetconfig.c b/src/getnetconfig.c
index 9acd8c7..afbf8b5 100644
--- a/src/getnetconfig.c
+++ b/src/getnetconfig.c
@@ -507,9 +507,7 @@ getnetconfigent(netid)
 	    break;
 	}
     } while (stringp != NULL);
-    if (ncp == NULL) {
-	free(linep);
-    }
+    free(linep);
     fclose(file);
     return(ncp);
 }
-- 
2.39.0

Re: [PATCH] [nfs/nfs-utils/libtirpc] getnetconfig.c: free linep to avoid memory leakage

From: Steve Dickson <hidden>
Date: 2024-11-11 17:33:14


On 2/1/23 4:57 AM, Zhi Li wrote:
Signed-off-by: Zhi Li<redacted>
Committed... (tag: libtirpc-1-3-7-rc1)

steved.
quoted hunk
---
  src/getnetconfig.c | 4 +---
  1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/src/getnetconfig.c b/src/getnetconfig.c
index 9acd8c7..afbf8b5 100644
--- a/src/getnetconfig.c
+++ b/src/getnetconfig.c
@@ -507,9 +507,7 @@ getnetconfigent(netid)
  	    break;
  	}
      } while (stringp != NULL);
-    if (ncp == NULL) {
-	free(linep);
-    }
+    free(linep);
      fclose(file);
      return(ncp);
  }
-- 2.39.0
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help