From 2c1771259f391a24c3279a51923e1bd191905ca0 Mon Sep 17 00:00:00 2001 From: Erik de Castro Lopo Date: Thu, 6 Nov 2008 10:11:44 +1100 Subject: [PATCH] src/broadcast.c : Fix checking of required coding_history_size. --- ChangeLog | 3 +++ src/broadcast.c | 11 +++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 395c1489..3382d25f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,6 +7,9 @@ * programs/test-sndfile-metadata-set.py Add test for the above. + * src/broadcast.c + Fix checking of required coding_history_size. + 2008-10-28 Erik de Castro Lopo * tests/command_test.c diff --git a/src/broadcast.c b/src/broadcast.c index 180677ee..58f13e12 100644 --- a/src/broadcast.c +++ b/src/broadcast.c @@ -66,10 +66,13 @@ broadcast_var_set (SF_PRIVATE *psf, const SF_BROADCAST_INFO * info, size_t datas added_history_len = gen_coding_history (added_history, sizeof (added_history), &(psf->sf)) ; - if (psf->broadcast_var != NULL - && psf->broadcast_var->binfo.coding_history_size + added_history_len < datasize) - { free (psf->broadcast_var) ; - psf->broadcast_var = NULL ; + if (psf->broadcast_var != NULL) + { size_t coding_hist_offset = offsetof (SF_BROADCAST_INFO, coding_history) ; + + if (psf->broadcast_var->binfo.coding_history_size + added_history_len < datasize - coding_hist_offset) + { free (psf->broadcast_var) ; + psf->broadcast_var = NULL ; + } ; } ; if (psf->broadcast_var == NULL)