summaryrefslogtreecommitdiffstats
path: root/src/compiler
diff options
context:
space:
mode:
authorNicolai Hähnle <[email protected]>2016-11-03 10:23:17 +0100
committerNicolai Hähnle <[email protected]>2016-11-04 10:28:08 +0100
commitaef7eb4cacbb241dc895f3e08dba4c91052a98a8 (patch)
treeb5df99c8105711414533ef36a66bdba2d37cca1b /src/compiler
parent8ce7ef75f5d164bfe9eae23749e83b6a88e2b270 (diff)
glsl/cache: correct asprintf error handling
From the manpage of asprintf: "If memory allocation wasn't possible, or some other error occurs, these functions will return -1, and the contents of strp are undefined." Reviewed-by: Iago Toral Quiroga <[email protected]> Reviewed-by: Edward O'Callaghan <[email protected]>
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/glsl/cache.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/compiler/glsl/cache.c b/src/compiler/glsl/cache.c
index 64a34f06217..e74c27d3000 100644
--- a/src/compiler/glsl/cache.c
+++ b/src/compiler/glsl/cache.c
@@ -416,7 +416,8 @@ choose_random_file_matching(const char *dir_path,
return NULL;
}
- asprintf(&filename, "%s/%s", dir_path, entry->d_name);
+ if (asprintf(&filename, "%s/%s", dir_path, entry->d_name) < 0)
+ filename = NULL;
closedir(dir);
@@ -497,8 +498,7 @@ evict_random_item(struct program_cache *cache)
a = rand() % 16;
b = rand() % 16;
- asprintf (&dir_path, "%s/%c%c", cache->path, hex[a], hex[b]);
- if (dir_path == NULL)
+ if (asprintf(&dir_path, "%s/%c%c", cache->path, hex[a], hex[b]) < 0)
return;
size = unlink_random_file_from_directory(dir_path);