Fix memleak in WebPIDelete (change#Id4faef1b).

Corresponding bug for this fix is b/10823924

Happens when decoding is partial (past Partition0), without error and
interrupted by calling WebPIDelete()
WebPIDelete() needs to call VP8ExitCritical() to free in-flight
resources.

The upstream change for WebP has landed WebP git via gerrit patch:
https://gerrit.chromium.org/gerrit/#/c/67199/


Change-Id: Iae0fb5d1bd239f9641503f08ffb79780da7aa42f
diff --git a/ChangeLog b/ChangeLog
index 1a703f3..e3b9abb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -6,3 +6,4 @@
 -     : Updated WebP with head change#I3da2063b
 - 3/13: Updated WebP with head change#I9e5ae737
 - 8/13: Release version 0.3.1 (head change#Idea3464b)
+- 9/13: Fix memleak in WebPIDelete() (change#Id4faef1b)
diff --git a/README.android b/README.android
index 814b378..e2fc261 100644
--- a/README.android
+++ b/README.android
@@ -37,6 +37,7 @@
   - Add incremental decoding support for images containing ALPH and ICCP chunks.
 - Updated WebP with patches required for Animation
    (#I737451d7f, #Ia300385a & #I9566a8e2).
+- Fix memleak in WebPIDelete() (change#Id4faef1b).
 
 The Android.mk file creates WebP Decoder and Encoder static libraries which
 can be added to any application by Adding to LOCAL_STATIC_LIBRARIES
diff --git a/src/dec/idec.c b/src/dec/idec.c
index 5fbf49a..61635ec 100644
--- a/src/dec/idec.c
+++ b/src/dec/idec.c
@@ -606,6 +606,10 @@
   if (idec == NULL) return;
   if (idec->dec_ != NULL) {
     if (!idec->is_lossless_) {
+      if (idec->state_ == STATE_VP8_DATA) {
+        // Synchronize the thread, clean-up and check for errors.
+        VP8ExitCritical(idec->dec_, &idec->io_);
+      }
       VP8Delete(idec->dec_);
     } else {
       VP8LDelete(idec->dec_);