Signed-off-by: Juha-Pekka Heikkila <[email protected]>
---
src/mesa/program/symbol_table.c | 26 +++++++++++++++++++++++---
1 file changed, 23 insertions(+), 3 deletions(-)
diff --git a/src/mesa/program/symbol_table.c b/src/mesa/program/symbol_table.c
index 64e24d8..df1ec5c 100644
--- a/src/mesa/program/symbol_table.c
+++ b/src/mesa/program/symbol_table.c
@@ -188,9 +188,11 @@ _mesa_symbol_table_push_scope(struct _mesa_symbol_table
*table)
{
struct scope_level *const scope = calloc(1, sizeof(*scope));
- scope->next = table->current_scope;
- table->current_scope = scope;
- table->depth++;
+ if (scope) {
+ scope->next = table->current_scope;
+ table->current_scope = scope;
+ table->depth++;
+ }
}
@@ -338,6 +340,11 @@ _mesa_symbol_table_add_symbol(struct _mesa_symbol_table
*table,
if (hdr == NULL) {
hdr = calloc(1, sizeof(*hdr));
+
+ if (hdr == NULL) {
+ return -1;
+ }
+
hdr->name = strdup(name);
hash_table_insert(table->ht, hdr, hdr->name);
@@ -360,6 +367,11 @@ _mesa_symbol_table_add_symbol(struct _mesa_symbol_table
*table,
return -1;
sym = calloc(1, sizeof(*sym));
+
+ if (sym == NULL) {
+ return -1;
+ }
+
sym->next_with_same_name = hdr->symbols;
sym->next_with_same_scope = table->current_scope->symbols;
sym->hdr = hdr;
@@ -395,6 +407,10 @@ _mesa_symbol_table_add_global_symbol(struct
_mesa_symbol_table *table,
if (hdr == NULL) {
hdr = calloc(1, sizeof(*hdr));
+ if (hdr == NULL) {
+ return -1;
+ }
+
hdr->name = strdup(name);
hash_table_insert(table->ht, hdr, hdr->name);
@@ -424,6 +440,10 @@ _mesa_symbol_table_add_global_symbol(struct
_mesa_symbol_table *table,
}
sym = calloc(1, sizeof(*sym));
+ if (sym == NULL) {
+ return -1;
+ }
+
sym->next_with_same_scope = top_scope->symbols;
sym->hdr = hdr;
sym->name_space = name_space;
--
1.8.1.2
_______________________________________________
mesa-dev mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/mesa-dev