Internal change

PiperOrigin-RevId: 146936155
Change-Id: Id82a8009c88bcf5c6472e993d0758a56e5271aea
diff --git a/src/mp4file.cpp b/src/mp4file.cpp
index 86f386b..8597154 100644
--- a/src/mp4file.cpp
+++ b/src/mp4file.cpp
@@ -190,6 +190,8 @@
             // get rid of any trailing free or skips
             if (!strcmp(type, "free") || !strcmp(type, "skip")) {
                 m_pRootAtom->DeleteChildAtom(pAtom);
+                // Make sure to deallocate the atom before removing.
+                delete pAtom;
                 continue;
             }
 
@@ -1991,7 +1993,7 @@
                 uint32_t seqlen;
                 pUnit->GetValue(&seq, &seqlen, index);
                 if (memcmp(seq, pPict, pictLen) == 0) {
-                    log.verbose1f("\"%s\": picture matches %d", 
+                    log.verbose1f("\"%s\": picture matches %d",
                                   GetFilename().c_str(), index);
                     free(seq);
                     return;
@@ -3043,7 +3045,7 @@
 
 void MP4File::WriteSampleDependency(
     MP4TrackId     trackId,
-    const uint8_t* pBytes, 
+    const uint8_t* pBytes,
     uint32_t       numBytes,
     MP4Duration    duration,
     MP4Duration    renderingOffset,
@@ -3198,7 +3200,7 @@
     return true;
 }
 
-    
+
 bool MP4File::GetTrackName( MP4TrackId trackId, char** name )
 {
     unsigned char *val = NULL;
@@ -3241,7 +3243,7 @@
     {
         if (!AddDescendantAtoms(MakeTrackName(trackId, NULL), "udta.name"))
             return false;
-        
+
         pMetaAtom = m_pRootAtom->FindAtom(atomstring);
         if (pMetaAtom == NULL) return false;
     }
@@ -3417,7 +3419,7 @@
         FindAtom(MakeTrackName(trackId,
                                "mdia.minf.stbl.stsd"));
     if (pAtom->GetNumberOfChildAtoms() != 1) {
-        log.errorf("%s: \"%s\": track %d has more than 1 child atoms in stsd", 
+        log.errorf("%s: \"%s\": track %d has more than 1 child atoms in stsd",
                    __FUNCTION__, GetFilename().c_str(), trackId);
         return NULL;
     }
@@ -4331,7 +4333,7 @@
 
     //if( ismacrypEncryptSampleAddHeader( ismaCryptSId, numBytes, pBytes, &encSampleLength, &encSampleData ) != 0)
     if( encfcnp( encfcnparam1, numBytes, pBytes, &encSampleLength, &encSampleData ) != 0 )
-        log.errorf("%s(%s,%s) Can't encrypt the sample and add its header %u", 
+        log.errorf("%s(%s,%s) Can't encrypt the sample and add its header %u",
                    __FUNCTION__, srcFile->GetFilename().c_str(), dstFile->GetFilename().c_str(), srcSampleId );
 
     if( hasDependencyFlags ) {