echo-cancel: Fix a crash is speex cleanup
authorArun Raghavan <arun.raghavan@collabora.co.uk>
Sat, 28 May 2011 02:21:35 +0000 (07:51 +0530)
committerArun Raghavan <arun.raghavan@collabora.co.uk>
Sat, 28 May 2011 02:29:49 +0000 (07:59 +0530)
If module initialisation fails, the speex done() function might try to
free a value that's not been allocated yet. Adding protection for this
condition.

src/modules/echo-cancel/speex.c

index ce361fc..72c5268 100644 (file)
@@ -109,6 +109,7 @@ void pa_speex_ec_run(pa_echo_canceller *ec, const uint8_t *rec, const uint8_t *p
 }
 
 void pa_speex_ec_done(pa_echo_canceller *ec) {
-    speex_echo_state_destroy(ec->params.priv.speex.state);
+    if (ec->params.priv.speex.state)
+        speex_echo_state_destroy(ec->params.priv.speex.state);
     ec->params.priv.speex.state = NULL;
 }