[PATCH] Do not pass null pointer to freeaddrinfo()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Passing null pointer as input parameter to freeaddrinfo() is undefined
behaviour, some libcs e.g. glibc might just call free() which does
accept null pointer but other libcs e.g. musl might not and instead
cause the program to segfault. Therefore do not rely on undefined
behaviour instead make it deterministic

Signed-off-by: Khem Raj <raj.khem@xxxxxxxxx>
---
 support/export/client.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Index: nfs-utils-2.3.2/support/export/client.c
===================================================================
--- nfs-utils-2.3.2.orig/support/export/client.c
+++ nfs-utils-2.3.2/support/export/client.c
@@ -309,7 +309,8 @@ client_lookup(char *hname, int canonical
 		init_addrlist(clp, ai);
 
 out:
-	freeaddrinfo(ai);
+	if (ai)
+		freeaddrinfo(ai);
 	return clp;
 }
 



[Index of Archives]     [Linux Filesystem Development]     [Linux USB Development]     [Linux Media Development]     [Video for Linux]     [Linux NILFS]     [Linux Audio Users]     [Yosemite Info]     [Linux SCSI]

  Powered by Linux