]> git.xonotic.org Git - xonotic/gmqcc.git/commitdiff
Sanity check
authorDale Weiler <killfieldengine@gmail.com>
Fri, 27 Apr 2012 09:33:02 +0000 (05:33 -0400)
committerDale Weiler <killfieldengine@gmail.com>
Fri, 27 Apr 2012 09:33:02 +0000 (05:33 -0400)
gmqcc.h
typedef.c

diff --git a/gmqcc.h b/gmqcc.h
index 7eb835907115b3291371e3c75e90892457c517dc..d767b7b547c88477d98ab950a8ef62d0cbc88d63 100644 (file)
--- a/gmqcc.h
+++ b/gmqcc.h
@@ -93,7 +93,6 @@
 typedef char uint8_size_is_correct  [sizeof(uint8_t)  == 1?1:-1];
 typedef char uint16_size_if_correct [sizeof(uint16_t) == 2?1:-1];
 typedef char uint32_size_is_correct [sizeof(uint32_t) == 4?1:-1];
-//typedef char int8_size_is_correct   [sizeof(int8_t)   == 1?1:-1];
 typedef char int16_size_if_correct  [sizeof(int16_t)  == 2?1:-1];
 typedef char int32_size_is_correct  [sizeof(int32_t)  == 4?1:-1];
 /* intptr_t / uintptr_t correct size check */
index d9be47817df95489a427cc26b268afa6496ca1d3..d51693ebd7d0560a2d108578d75a50953d532a42 100644 (file)
--- a/typedef.c
+++ b/typedef.c
@@ -63,15 +63,21 @@ int typedef_add(struct lex_file *file, const char *from, const char *to) {
         strncmp(from, "entity", sizeof("entity")) == 0 ||
         strncmp(from, "void",   sizeof("void"))   == 0) {
         
-        typedef_table[hash]       = mem_a(sizeof(typedef_node));
-        typedef_table[hash]->name = util_strdup(from);
+        typedef_table[hash] = mem_a(sizeof(typedef_node));
+        if (typedef_table[hash])
+            typedef_table[hash]->name = util_strdup(from);
+        else
+            return error(file, ERROR_PARSE, "ran out of resources for typedef %s\n", to);
         return -100;
     } else {
         /* search the typedefs for it (typedef-a-typedef?) */
         typedef_node *find = typedef_table[typedef_hash(from)];
         if (find) {
             typedef_table[hash]       = mem_a(sizeof(typedef_node));
-            typedef_table[hash]->name = util_strdup(find->name);
+            if (typedef_table[hash])
+                typedef_table[hash]->name = util_strdup(find->name);
+            else
+                return error(file, ERROR_PARSE, "ran out of resources for typedef %s\n", to);
             return -100;
         }
     }