Repository : ssh://git@open-mesh.org/alfred
On branch : master
commit 4da3dca651bc2b77fb3459b2e14eb00674b69af7 Author: Sven Eckelmann sven@open-mesh.com Date: Wed May 22 04:55:21 2013 -0700
alfred: Set length of dataset to zero after freeing
The buffer allocation can fail for malloc and the length of the data would still be != 0. Resetting it 0 should reduce the chance of an inconsistent view on the stored data.
Signed-off-by: Sven Eckelmann sven@open-mesh.com
4da3dca651bc2b77fb3459b2e14eb00674b69af7 recv.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/recv.c b/recv.c index ffabba5..6292df0 100644 --- a/recv.c +++ b/recv.c @@ -76,8 +76,11 @@ static int finish_alfred_push_data(struct globals *globals, clock_gettime(CLOCK_MONOTONIC, &dataset->last_seen);
/* free old buffer */ - if (dataset->buf) + if (dataset->buf) { free(dataset->buf); + dataset->data.header.length = 0; + } + dataset->buf = malloc(data_len);
/* that's not good */