From: Wolfram Sang Date: Fri, 19 Feb 2016 21:25:00 +0000 (+0100) Subject: linux: freebsd: do check on proper pointer X-Git-Tag: libserialport-unreleased^0 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=0c3f38b81b8968d78806a7a41ed351a870882b5e;p=libserialport.git linux: freebsd: do check on proper pointer We want to check here if we added something to the list, not if the function argument was valid. Problem spotted by Coverity, CID 50754. Signed-off-by: Wolfram Sang --- diff --git a/freebsd.c b/freebsd.c index b5cd91a..387b2f8 100644 --- a/freebsd.c +++ b/freebsd.c @@ -373,7 +373,7 @@ SP_PRIV enum sp_return list_ports(struct sp_port ***list) DBG("%s: %s\n", __func__, entry.d_name); *list = list_append(*list, name); - if (!list) { + if (!*list) { SET_ERROR(ret, SP_ERR_MEM, "List append failed"); break; } diff --git a/linux.c b/linux.c index 9016489..f7dc8fd 100644 --- a/linux.c +++ b/linux.c @@ -236,7 +236,7 @@ SP_PRIV enum sp_return list_ports(struct sp_port ***list) } DEBUG_FMT("Found port %s", name); *list = list_append(*list, name); - if (!list) { + if (!*list) { SET_ERROR(ret, SP_ERR_MEM, "List append failed"); break; }