diff mbox

[i-g-t] lib: Make sure we don't use a negative offset

Message ID 20170106140320.2476-1-tomeu.vizoso@collabora.com (mailing list archive)
State New, archived
Headers show

Commit Message

Tomeu Vizoso Jan. 6, 2017, 2:03 p.m. UTC
As bytes_read can contain an error condition under some circumstances,
in which we want to error out.

Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
---
 lib/igt_debugfs.c | 1 +
 1 file changed, 1 insertion(+)
diff mbox

Patch

diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c
index d828687a62ca..b1b67e740041 100644
--- a/lib/igt_debugfs.c
+++ b/lib/igt_debugfs.c
@@ -601,6 +601,7 @@  static int read_crc(igt_pipe_crc_t *pipe_crc, igt_crc_t *out)
 		igt_assert(pipe_crc->flags & O_NONBLOCK);
 		bytes_read = 0;
 	}
+	igt_assert_lte(0, bytes_read);
 	buf[bytes_read] = '\0';
 
 	if (bytes_read && !pipe_crc_init_from_string(pipe_crc, out, buf))