summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatt Turner <[email protected]>2015-03-03 16:09:58 -0800
committerMatt Turner <[email protected]>2015-03-04 11:15:09 -0800
commitade0b580e75bdea227eec5345f6681b678d0811b (patch)
tree6df88aafc486148f39cc4a700e3da8c5db97584f /src
parentf5e2aa1324dd6a9666bb21834097d2fbc3cb99b6 (diff)
r300g: Check return value of snprintf().
Would have at least prevented the crash the previous patch fixed. Cc: 10.4, 10.5 <[email protected]> Bugzilla: https://bugs.gentoo.org/show_bug.cgi?id=540970 Reviewed-by: Tom Stellard <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/gallium/drivers/r300/compiler/tests/rc_test_helpers.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/gallium/drivers/r300/compiler/tests/rc_test_helpers.c b/src/gallium/drivers/r300/compiler/tests/rc_test_helpers.c
index 422bdb04405..04c01f1b443 100644
--- a/src/gallium/drivers/r300/compiler/tests/rc_test_helpers.c
+++ b/src/gallium/drivers/r300/compiler/tests/rc_test_helpers.c
@@ -541,9 +541,14 @@ unsigned load_program(
unsigned *count;
char **string_store;
unsigned i = 0;
+ int n;
memset(line, 0, sizeof(line));
- snprintf(path, PATH_MAX, TEST_PATH "/%s", filename);
+ n = snprintf(path, PATH_MAX, TEST_PATH "/%s", filename);
+ if (n < 0 || n >= PATH_MAX) {
+ return 0;
+ }
+
file = fopen(path, "r");
if (!file) {
return 0;