Bug 879924 - Don't shorten zero-length strings. r=derf
authorRalph Giles <giles@mozilla.com>
Mon, 10 Jun 2013 17:10:09 -0700
changeset 146135 2912073936087029874748e744c7a55278dc07cf
parent 146134 0acda90a6f6aac6dc970afaabab158183703d18f
child 146140 4e6b77e3ddd524b0086d947c9ee17223f67e99c9
push id2697
push userbbajaj@mozilla.com
push dateMon, 05 Aug 2013 18:49:53 +0000
treeherdermozilla-beta@dfec938c7b63 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersderf
bugs879924
milestone24.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 879924 - Don't shorten zero-length strings. r=derf We were trying to strip the optional null terminator even when we knew there wasn't one there.
content/media/wave/WaveReader.cpp
--- a/content/media/wave/WaveReader.cpp
+++ b/content/media/wave/WaveReader.cpp
@@ -574,18 +574,20 @@ WaveReader::LoadListChunk(uint32_t aChun
 
     uint32_t length = ReadUint32LE(&p);
 
     // Subchunk shall not exceed parent chunk.
     if (p + length > end) {
       break;
     }
 
+    // Wrap the string, adjusting length to account for optional
+    // null termination in the chunk.
     nsCString val(p, length);
-    if (val[length - 1] == '\0') {
+    if (length > 0 && val[length - 1] == '\0') {
       val.SetLength(length - 1);
     }
 
     // Chunks in List::INFO are always word (two byte) aligned. So round up if
     // necessary.
     length += length % 2;
     p += length;