[Piglit] [PATCH] cl: Guard against CL version overflow.

Vinson Lee vlee at freedesktop.org
Thu Jul 6 21:59:08 UTC 2017


Fix Coverity overflowed return value defect.

CID: 1364163
Signed-off-by: Vinson Lee <vlee at freedesktop.org>
---
 tests/util/piglit-framework-cl.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/tests/util/piglit-framework-cl.c b/tests/util/piglit-framework-cl.c
index 235f160877cf..31346b7d8a17 100644
--- a/tests/util/piglit-framework-cl.c
+++ b/tests/util/piglit-framework-cl.c
@@ -450,6 +450,7 @@ piglit_cl_get_version_arg(int argc, const char** argv)
 {
 	int version_major = 0;
 	int version_minor = 0;
+	int version;
 
 	const char* version_str;
 
@@ -466,7 +467,12 @@ piglit_cl_get_version_arg(int argc, const char** argv)
 		}
 	}
 
-	return version_major*10 + version_minor;
+	version = version_major*10 + version_minor;
+	if (version < 0) {
+		version = 0;
+	}
+
+	return version;
 }
 
 bool
-- 
2.11.0



More information about the Piglit mailing list