C2SoftXaacDec: Handle multiple onRelease calls

Set allocated pointers to null after free to handle multiple calls to
onRelease() and avoid an use after free error.

Bug: 110441447
Test: -m CtsMediaTestCases -t android.media.cts.MediaCodecCapabilitiesTest#\
       testGetMaxSupportedInstances

Change-Id: Iab9af0c5b82ccf85fdc2f6fd2fd98ceb1ede038b
diff --git a/media/codecs/xaac/C2SoftXaacDec.cpp b/media/codecs/xaac/C2SoftXaacDec.cpp
index d77dd9e..ed5290a 100644
--- a/media/codecs/xaac/C2SoftXaacDec.cpp
+++ b/media/codecs/xaac/C2SoftXaacDec.cpp
@@ -894,21 +894,21 @@
 IA_ERRORCODE C2SoftXaacDec::deInitXAACDecoder() {
     ALOGV("deInitXAACDecoder");
 
-    /* Error code */
     IA_ERRORCODE err_code = IA_NO_ERROR;
-
-    /* Tell that the input is over in this buffer */
-    err_code = ixheaacd_dec_api(mXheaacCodecHandle,
-                                IA_API_CMD_INPUT_OVER,
-                                0,
-                                NULL);
-
+    if (mXheaacCodecHandle) {
+        /* Tell that the input is over in this buffer */
+        err_code = ixheaacd_dec_api(mXheaacCodecHandle,
+                                    IA_API_CMD_INPUT_OVER,
+                                    0,
+                                    NULL);
+        mXheaacCodecHandle = nullptr;
+    }
     /* Irrespective of error returned in IA_API_CMD_INPUT_OVER, free allocated memory */
     for (void* buf : mMemoryVec) {
         free(buf);
     }
     mMemoryVec.clear();
-
+    mMpegDDrcHandle = nullptr;
     return err_code;
 }