From 50dd443c20588ef0575fdb0171cce59ba49c77ec Mon Sep 17 00:00:00 2001 From: Stefan Westerfeld Date: Mon, 21 Oct 2019 17:36:23 +0200 Subject: [PATCH] Fix bugs in fluid_sample_set_sound_data with copy enabled - memset should clear all the memory - end position should be at the end of sample data Closes #576 Signed-off-by: Stefan Westerfeld --- src/sfloader/fluid_sfont.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sfloader/fluid_sfont.c b/src/sfloader/fluid_sfont.c index 04dd0017..3551f719 100644 --- a/src/sfloader/fluid_sfont.c +++ b/src/sfloader/fluid_sfont.c @@ -608,7 +608,7 @@ fluid_sample_set_sound_data(fluid_sample_t *sample, goto error_rec; } - FLUID_MEMSET(sample->data, 0, storedNbFrames); + FLUID_MEMSET(sample->data, 0, storedNbFrames * sizeof(short)); FLUID_MEMCPY(sample->data + SAMPLE_LOOP_MARGIN, data, nbframes * sizeof(short)); if(data24 != NULL) @@ -627,7 +627,7 @@ fluid_sample_set_sound_data(fluid_sample_t *sample, /* pointers */ /* all from the start of data */ sample->start = SAMPLE_LOOP_MARGIN; - sample->end = SAMPLE_LOOP_MARGIN + storedNbFrames - 1; + sample->end = SAMPLE_LOOP_MARGIN + nbframes - 1; } else {