]> sigrok.org Git - libsigrok.git/commitdiff
serial: Check event ptr before using.
authorBert Vermeulen <redacted>
Sun, 16 Aug 2015 18:03:10 +0000 (20:03 +0200)
committerBert Vermeulen <redacted>
Sun, 30 Aug 2015 18:42:54 +0000 (20:42 +0200)
This avoids a NULL dereference when called twice.

src/serial.c

index d3cacba932c53aad89c4fdacdb782bce1c61f04f..25e2b97b3ce63ef30e04317e50c9e3b7303462f2 100644 (file)
@@ -843,6 +843,9 @@ SR_PRIV int serial_source_remove(struct sr_session *session,
 {
        unsigned int i;
 
+       if (!serial->event_set)
+               return SR_OK;
+
        for (i = 0; i < serial->event_set->count; i++)
                if (sr_session_source_remove_pollfd(session, &serial->pollfds[i]) != SR_OK)
                        return SR_ERR;