diff options
author | Peter Harris <pharris@opentext.com> | 2010-09-10 15:51:56 -0400 |
---|---|---|
committer | Peter Harris <pharris@opentext.com> | 2010-09-22 22:20:04 -0400 |
commit | 28a71c6567d08272dc9c1c2b32f0529f11f62b9e (patch) | |
tree | e7c3a96560b8fd96dab53c4edd3f50515db99773 | |
parent | a22909c0f513fe28347c56be65a345831c3ce744 (diff) |
Fix memory leak in _sizeof implemented with _unserialize
Signed-off-by: Peter Harris <pharris@opentext.com>
-rw-r--r-- | src/c_client.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/c_client.py b/src/c_client.py index 85ae09b..08d6ec4 100644 --- a/src/c_client.py +++ b/src/c_client.py @@ -1134,8 +1134,7 @@ def _c_serialize(context, self): return elif self.var_followed_by_fixed_fields: # special case: call _unserialize() - _c(' %s *_aux = NULL;', self.c_type) - _c(' return %s(%s, &_aux);', self.c_unserialize_name, reduce(lambda x,y: "%s, %s" % (x, y), param_names)) + _c(' return %s(%s, NULL);', self.c_unserialize_name, reduce(lambda x,y: "%s, %s" % (x, y), param_names)) _c('}') return else: @@ -1180,6 +1179,12 @@ def _c_serialize(context, self): # allocate memory and copy everything into a continuous memory area # note: this is not necessary in case of unpack if context in ('serialize', 'unserialize'): + # unserialize: check for sizeof-only invocation + if 'unserialize' == context: + _c('') + _c(' if (NULL == _aux)') + _c(' return xcb_buffer_len;') + _c('') _c(' if (NULL == %s) {', aux_ptr) _c(' /* allocate memory */') |