summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Haberman <jhaberman@gmail.com>2011-08-10 19:43:52 -0700
committerJoshua Haberman <jhaberman@gmail.com>2011-08-10 19:43:52 -0700
commitbe7457245594fdc56ee23306eb6e3962f7333fc7 (patch)
tree66f23b8157ff1574177a2edb36d288bb4b0ab33c
parentfc9c49860b56ce13fc24e1c309431fffa1e84804 (diff)
Fixed off-by-one stack allocation error.
-rw-r--r--lang_ext/python/upb.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/lang_ext/python/upb.c b/lang_ext/python/upb.c
index d82fba8..b6a1ab6 100644
--- a/lang_ext/python/upb.c
+++ b/lang_ext/python/upb.c
@@ -78,7 +78,7 @@ static PyObject *weakref_callback = NULL;
static PyObject *PyUpb_ObjCacheDeleteCallback(PyObject *self, PyObject *ref) {
// Remove the value from the weak table.
PyUpb_ObjWrapper *tmp = (PyUpb_ObjWrapper*)PyWeakref_GetObject(ref);
- char key[sizeof(void*)];
+ char key[sizeof(void*) + 1];
key[sizeof(void*)] = '\0';
memcpy(key, &tmp->obj, sizeof(void*));
PyDict_DelItemString(obj_cache, key);
@@ -86,7 +86,7 @@ static PyObject *PyUpb_ObjCacheDeleteCallback(PyObject *self, PyObject *ref) {
}
static PyObject *PyUpb_ObjCacheGet(void *obj, PyTypeObject *type) {
- char key[sizeof(void*)];
+ char key[sizeof(void*) + 1];
key[sizeof(void*)] = '\0';
memcpy(key, &obj, sizeof(void*));
PyObject *ref = PyDict_GetItemString(obj_cache, key);
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback