hyu163 / mp4v2

Automatically exported from code.google.com/p/mp4v2
Other
0 stars 0 forks source link

Bug fixes for mpeg4ip-1.6.1 which might still apply to mp4v2 #47

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
As egroenen requested in 
https://sourceforge.net/projects/mpeg4ip/forums/forum/59136/topic/2427643 
here are some patches for bugs in mpeg4ip-1.6.1

--- C:/Users/dev/AppData/Local/Temp/mp4util.cpp Wed Dec  9 16:17:56 2009
+++ C:/Builds/Work/project/trunk/External/mpeg4ip-
1.6.1/lib/mp4v2/mp4util.cpp Tue Dec  8 17:52:18 2009
@@ -89,7 +89,7 @@
        if (*s2 == '\0' || strchr("[.", *s2)) {
            break;
        }
-       if (tolower(*s1) != tolower(*s2)) {
+       if (tolower((unsigned char)*s1) != tolower((unsigned char)
*s2)) {
            return false;
        }
        s1++;

--- C:/Users/dev/AppData/Local/Temp/atom_hdlr.cpp   Wed Dec  9 16:18:31 2009
+++ C:/Builds/Work/project/trunk/External/mpeg4ip-
1.6.1/lib/mp4v2/atom_hdlr.cpp   Tue Dec  8 17:52:18 2009
@@ -46,6 +46,12 @@
    uint64_t end = GetEnd();
    if (pos == end) return;

+    // A hdlr atom with missing "name". 
+    // Apparently that's what some of the iTunes m4p files have.
+    if (m_pFile->GetPosition() == GetEnd()) {
+        return;
+    }
+
    // take a peek at the next byte
    u_int8_t strLength;
    m_pFile->PeekBytes(&strLength, 1);

--- C:/Users/dev/AppData/Local/Temp/mp4atom.cpp Wed Dec  9 16:19:02 2009
+++ C:/Builds/Work/project/trunk/External/mpeg4ip-
1.6.1/lib/mp4v2/mp4atom.cpp Tue Dec  8 17:52:18 2009
@@ -406,7 +406,13 @@

    pAtom->SetParentAtom(pParentAtom);

-   pAtom->Read();
+    try {
+       pAtom->Read();
+    }
+    catch (MP4Error* e) {
+        delete pAtom;
+        throw e;
+    }

    return pAtom;
 }
@@ -414,7 +420,7 @@
 bool MP4Atom::IsReasonableType(const char* type)
 {
    for (u_int8_t i = 0; i < 4; i++) {
-       if (isalnum(type[i])) {
+       if (isalnum((unsigned char)type[i])) {
            continue;
        }
        if (i == 3 && type[i] == ' ') {

Original issue reported on code.google.com by saint...@gmail.com on 10 Dec 2009 at 12:36

GoogleCodeExporter commented 8 years ago
The middle change (hdlr atom with missing name) is already in the build, 
although I
added the comment so people know why that code is present.

I added the code to catch/delete/rethrow around pAtom->Read(), it prevents 
leaking
memory (about ~7 KB on my test file that throws there, nice!) when reading an 
invalid
file, so that's a great change.

The other two, I don't understand--they don't seem to be casting to the right 
type. 
If you can let me know why, I'll add those changes.

Changes are in r377.   

Thanks!

Original comment by kid...@gmail.com on 4 Apr 2010 at 12:34