summaryrefslogtreecommitdiffstats
path: root/src/mapi/glapi
diff options
context:
space:
mode:
authorCarl Worth <[email protected]>2014-09-03 14:18:18 -0700
committerCarl Worth <[email protected]>2014-09-03 18:37:02 -0700
commitc35f14f36880eb20f5e54480444e343520e9bec5 (patch)
tree860639f711be92e6ee031b005ac0284320c91d39 /src/mapi/glapi
parent96ce065db46d11f5ad6423f4a522f3e92153b3cf (diff)
Eliminate several cases of multiplication in arguments to calloc
In commit 32f2fd1c5d6088692551c80352b7d6fa35b0cd09, several calls to _mesa_calloc(x) were replaced with calls to calloc(1, x). This is strictly equivalent to what the code was doing previously. But for cases where "x" involves multiplication, now that we are explicitly using the two-argument calloc, we can do one step better and replace: calloc(1, A * B); with: calloc(A, B); The advantage of the latter is that calloc will detect any overflow that would have resulted from the multiplication and will fail the allocation, (whereas the former would return a small allocation). So this fix can change potentially exploitable buffer overruns into segmentation faults. Reviewed-by: Matt Turner <[email protected]>
Diffstat (limited to 'src/mapi/glapi')
-rw-r--r--src/mapi/glapi/gen/gl_gentable.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/mapi/glapi/gen/gl_gentable.py b/src/mapi/glapi/gen/gl_gentable.py
index 7577b66a61b..ce9af99d50c 100644
--- a/src/mapi/glapi/gen/gl_gentable.py
+++ b/src/mapi/glapi/gen/gl_gentable.py
@@ -113,7 +113,7 @@ __glapi_gentable_set_remaining_noop(struct _glapi_table *disp) {
struct _glapi_table *
_glapi_create_table_from_handle(void *handle, const char *symbol_prefix) {
- struct _glapi_table *disp = calloc(1, _glapi_get_dispatch_table_size() * sizeof(_glapi_proc));
+ struct _glapi_table *disp = calloc(_glapi_get_dispatch_table_size(), sizeof(_glapi_proc));
char symboln[512];
if(!disp)