summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/formats.c
diff options
context:
space:
mode:
authorJuha-Pekka Heikkila <[email protected]>2015-03-20 15:40:26 +0200
committerJuha-Pekka Heikkila <[email protected]>2015-06-11 13:17:11 +0300
commit56e9f3b493a8677e60e4473ca0faf0e3d1a79888 (patch)
treefa713415523b77b617b73bdb97cd4876f1850c6c /src/mesa/main/formats.c
parentfd00c738c08e54c9dfdc195e59f780f30d2f9e07 (diff)
mesa/main: avoid null access in format_array_table_init()
If _mesa_hash_table_create failed we'd get null pointer. Report error and go away. Signed-off-by: Juha-Pekka Heikkila <[email protected]> Reviewed-by: Anuj Phogat <[email protected]>
Diffstat (limited to 'src/mesa/main/formats.c')
-rw-r--r--src/mesa/main/formats.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/mesa/main/formats.c b/src/mesa/main/formats.c
index 8af44e90520..f7c94024f65 100644
--- a/src/mesa/main/formats.c
+++ b/src/mesa/main/formats.c
@@ -397,6 +397,11 @@ format_array_format_table_init(void)
format_array_format_table = _mesa_hash_table_create(NULL, NULL,
array_formats_equal);
+ if (!format_array_format_table) {
+ _mesa_error_no_memory(__func__);
+ return;
+ }
+
for (f = 1; f < MESA_FORMAT_COUNT; ++f) {
info = _mesa_get_format_info(f);
if (!info->ArrayFormat)
@@ -432,6 +437,11 @@ _mesa_format_from_array_format(uint32_t array_format)
call_once(&format_array_format_table_exists, format_array_format_table_init);
+ if (!format_array_format_table) {
+ format_array_format_table_exists = ONCE_FLAG_INIT;
+ return MESA_FORMAT_NONE;
+ }
+
entry = _mesa_hash_table_search_pre_hashed(format_array_format_table,
array_format,
(void *)(intptr_t)array_format);