]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
snmp: avoid deferencing a pointer when it may be NULL
authorVincent Bernat <vincent@bernat.im>
Wed, 9 Jul 2014 06:50:04 +0000 (08:50 +0200)
committerVincent Bernat <vincent@bernat.im>
Wed, 9 Jul 2014 06:50:45 +0000 (08:50 +0200)
src/daemon/agent_priv.c

index 8efcb5e37cc4947fea6ce42ed73891827c215aee..6a126fe84134d616961b2326cecc15007035aae6 100644 (file)
@@ -84,12 +84,12 @@ agent_priv_unix_send(netsnmp_transport *t, void *buf, int size,
     void **opaque, int *olength)
 {
        int rc = -1;
-       struct pollfd sagentx = {
-               .fd = t->sock,
-               .events = POLLOUT | POLLERR | POLLHUP
-       };
 
        if (t != NULL && t->sock >= 0) {
+               struct pollfd sagentx = {
+                       .fd = t->sock,
+                       .events = POLLOUT | POLLERR | POLLHUP
+               };
                while (rc < 0) {
                        rc = poll(&sagentx, 1, AGENT_WRITE_TIMEOUT);
                        if (rc == 0) {