From 1622ef60b032522edfecca46bd23ec1bf4b0ee64 Mon Sep 17 00:00:00 2001 From: Martin Ling Date: Sat, 7 Dec 2013 16:50:27 +0000 Subject: [PATCH] Check return value of GetOverlappedResult(). --- serialport.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/serialport.c b/serialport.c index e42e757..b7dd66a 100644 --- a/serialport.c +++ b/serialport.c @@ -1155,7 +1155,8 @@ enum sp_return sp_nonblocking_read(struct sp_port *port, void *buf, size_t count RETURN_FAIL("ReadFile() failed"); /* Get number of bytes read. */ - GetOverlappedResult(port->hdl, &port->read_ovl, &bytes_read, TRUE); + if (GetOverlappedResult(port->hdl, &port->read_ovl, &bytes_read, TRUE) == 0) + RETURN_FAIL("GetOverlappedResult() failed"); RETURN_VALUE("%d", bytes_read); #else