From: Dale Weiler Date: Fri, 27 Apr 2012 09:33:02 +0000 (-0400) Subject: Sanity check X-Git-Tag: 0.1-rc1~578^2~7 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=422c085fbab8d98aae65f70cd2315b3c60673a26;p=xonotic%2Fgmqcc.git Sanity check --- diff --git a/gmqcc.h b/gmqcc.h index 7eb8359..d767b7b 100644 --- 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 */ diff --git a/typedef.c b/typedef.c index d9be478..d51693e 100644 --- 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; } }