]> sigrok.org Git - libserialport.git/commitdiff
linux: freebsd: do check on proper pointer libserialport-unreleased
authorWolfram Sang <redacted>
Fri, 19 Feb 2016 21:25:00 +0000 (22:25 +0100)
committerUwe Hermann <redacted>
Sun, 28 Feb 2016 17:01:25 +0000 (18:01 +0100)
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 <redacted>
freebsd.c
linux.c

index b5cd91a2af52546188e6e1bd417aad53b93d46ea..387b2f812548a196b90086c3574d86dc6fe8d5a2 100644 (file)
--- 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 9016489fb16f95afcedc2db0c9d8d2c8feb5a1f3..f7dc8fda7febfc97ec21b0934750d672aad773fc 100644 (file)
--- 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;
                }