compress_open() should delay taking a copy of the config struct until we've finished modifying it.
Signed-off-by: Richard Fitzgerald rf@opensource.wolfsonmicro.com --- compress.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/compress.c b/compress.c index 7f56c78..373de85 100644 --- a/compress.c +++ b/compress.c @@ -235,7 +235,6 @@ struct compress *compress_open(unsigned int card, unsigned int device, compress->config = calloc(1, sizeof(*config)); if (!compress->config) goto input_fail; - memcpy(compress->config, config, sizeof(*compress->config));
snprintf(fn, sizeof(fn), "/dev/snd/comprC%uD%u", card, device);
@@ -277,6 +276,8 @@ struct compress *compress_open(unsigned int card, unsigned int device, goto codec_fail; } #endif + + memcpy(compress->config, config, sizeof(*compress->config)); fill_compress_params(config, ¶ms);
if (ioctl(compress->fd, SNDRV_COMPRESS_SET_PARAMS, ¶ms)) {