summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--modules/mpa/decode.c14
-rw-r--r--modules/mpa/encode.c10
2 files changed, 15 insertions, 9 deletions
diff --git a/modules/mpa/decode.c b/modules/mpa/decode.c
index 7dfaccb..8a92fbc 100644
--- a/modules/mpa/decode.c
+++ b/modules/mpa/decode.c
@@ -51,12 +51,14 @@ int mpa_decode_update(struct audec_state **adsp, const struct aucodec *ac,
debug("MPA dec created %s\n",fmtp);
#endif
- if (ads)
- mem_deref(ads);
-
- ads = mem_zalloc(sizeof(*ads), destructor);
- if (!ads)
- return ENOMEM;
+ if (!ads) {
+ ads = mem_zalloc(sizeof(*ads), destructor);
+ if (!ads)
+ return ENOMEM;
+ }
+ else {
+ memset(ads,0,sizeof(*ads));
+ }
ads->channels = 0;
ads->resampler = NULL;
ads->start = 0;
diff --git a/modules/mpa/encode.c b/modules/mpa/encode.c
index 21a34c0..ec0b0a2 100644
--- a/modules/mpa/encode.c
+++ b/modules/mpa/encode.c
@@ -49,11 +49,15 @@ int mpa_encode_update(struct auenc_state **aesp, const struct aucodec *ac,
return EINVAL;
aes = *aesp;
- if (aes) {
- mem_deref(aes);
+ if (!aes) {
+ aes = mem_zalloc(sizeof(*aes), destructor);
+ if (!aes)
+ return ENOMEM;
+
}
+ else
+ memset(aes,0,sizeof(*aes));
- aes = mem_zalloc(sizeof(*aes), destructor);
aes->enc = twolame_init();
if (!aes->enc) {
error("MPA enc create failed\n");