aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa/main/extensions.c
diff options
context:
space:
mode:
Diffstat (limited to 'mesalib/src/mesa/main/extensions.c')
-rw-r--r--mesalib/src/mesa/main/extensions.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/mesalib/src/mesa/main/extensions.c b/mesalib/src/mesa/main/extensions.c
index 1903a503c..9cec15b58 100644
--- a/mesalib/src/mesa/main/extensions.c
+++ b/mesalib/src/mesa/main/extensions.c
@@ -37,6 +37,8 @@
#include "mfeatures.h"
#include "mtypes.h"
+#define ALIGN(value, alignment) (((value) + alignment - 1) & ~(alignment - 1))
+
enum {
DISABLE = 0,
GL = 1 << API_OPENGL,
@@ -769,11 +771,11 @@ get_extension_override( struct gl_context *ctx )
if (env_const == NULL) {
/* Return the empty string rather than NULL. This simplifies the logic
* of client functions. */
- return calloc(1, sizeof(char));
+ return calloc(4, sizeof(char));
}
/* extra_exts: List of unrecognized extensions. */
- extra_exts = calloc(strlen(env_const), sizeof(char));
+ extra_exts = calloc(ALIGN(strlen(env_const) + 2, 4), sizeof(char));
/* Copy env_const because strtok() is destructive. */
env = strdup(env_const);
@@ -907,7 +909,7 @@ _mesa_make_extension_string(struct gl_context *ctx)
if (extra_extensions != NULL)
length += 1 + strlen(extra_extensions); /* +1 for space */
- exts = (char *) calloc(length + 1, sizeof(char));
+ exts = (char *) calloc(ALIGN(length + 1, 4), sizeof(char));
if (exts == NULL) {
free(extra_extensions);
return NULL;