From be7457245594fdc56ee23306eb6e3962f7333fc7 Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Wed, 10 Aug 2011 19:43:52 -0700 Subject: Fixed off-by-one stack allocation error. --- lang_ext/python/upb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lang_ext') 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); -- cgit v1.2.3