From: Bert Vermeulen Date: Sun, 16 Aug 2015 18:03:10 +0000 (+0200) Subject: serial: Check event ptr before using. X-Git-Tag: libsigrok-0.4.0~363 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=2634b7781242796352616a571b794700f409baf7;p=libsigrok.git serial: Check event ptr before using. This avoids a NULL dereference when called twice. --- diff --git a/src/serial.c b/src/serial.c index d3cacba9..25e2b97b 100644 --- a/src/serial.c +++ b/src/serial.c @@ -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;