summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeorge Sapountzis <[email protected]>2010-03-08 01:40:14 +0200
committerGeorge Sapountzis <[email protected]>2010-03-10 18:44:45 +0200
commitcae4fdda8d27cac21714571adb0bfada6d96152a (patch)
treeedce4c5604e25aefa4e9c2ad654368c723a26e55
parentddabf0a151c2ef318e5de45238556c6568540681 (diff)
glapi: parameter checking, failure paths, ... for add_function_name
-rw-r--r--src/mesa/glapi/glapi_getproc.c38
1 files changed, 26 insertions, 12 deletions
diff --git a/src/mesa/glapi/glapi_getproc.c b/src/mesa/glapi/glapi_getproc.c
index a4d2cb907c9..ea905bb2cb4 100644
--- a/src/mesa/glapi/glapi_getproc.c
+++ b/src/mesa/glapi/glapi_getproc.c
@@ -293,20 +293,34 @@ static struct _glapi_function *
add_function_name( const char * funcName )
{
struct _glapi_function * entry = NULL;
-
- if (NumExtEntryPoints < MAX_EXTENSION_FUNCS) {
- _glapi_proc entrypoint = generate_entrypoint(~0);
- if (entrypoint != NULL) {
- entry = & ExtEntryTable[NumExtEntryPoints];
-
- ExtEntryTable[NumExtEntryPoints].name = str_dup(funcName);
- ExtEntryTable[NumExtEntryPoints].parameter_signature = NULL;
- ExtEntryTable[NumExtEntryPoints].dispatch_offset = ~0;
- ExtEntryTable[NumExtEntryPoints].dispatch_stub = entrypoint;
- NumExtEntryPoints++;
- }
+ _glapi_proc entrypoint = NULL;
+ char * name_dup = NULL;
+
+ if (NumExtEntryPoints >= MAX_EXTENSION_FUNCS)
+ return NULL;
+
+ if (funcName == NULL)
+ return NULL;
+
+ name_dup = str_dup(funcName);
+ if (name_dup == NULL)
+ return NULL;
+
+ entrypoint = generate_entrypoint(~0);
+
+ if (entrypoint == NULL) {
+ free(name_dup);
+ return NULL;
}
+ entry = & ExtEntryTable[NumExtEntryPoints];
+ NumExtEntryPoints++;
+
+ entry->name = name_dup;
+ entry->parameter_signature = NULL;
+ entry->dispatch_offset = ~0;
+ entry->dispatch_stub = entrypoint;
+
return entry;
}