File: 31-fix-utf16-stringlists.patch

package info (click to toggle)
id3lib3.8.3 3.8.3-19
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,640 kB
  • sloc: cpp: 12,364; sh: 9,186; ansic: 7,240; makefile: 355; php: 325
file content (24 lines) | stat: -rw-r--r-- 744 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
This patch fixes tag corruption after pipe characters.

Author: Urs Fleisch <urs.fleisch@gmail.com>
Fixes: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=680915
--- a/src/io_helpers.cpp
+++ b/src/io_helpers.cpp
@@ -373,10 +373,17 @@
     //}
     // Right code
     unsigned char *pdata = (unsigned char *) data.c_str();
+    unicode_t lastCh = BOM;
     for (size_t i = 0; i < size; i += 2)
     {
       unicode_t ch = (pdata[i] << 8) | pdata[i+1];
+      if (lastCh == 0 && ch != BOM)
+      {
+        // Last character was NULL, so start next string with BOM.
+        writer.writeChars((const unsigned char*) &BOM, 2);
+      }
       writer.writeChars((const unsigned char*) &ch, 2);
+      lastCh = ch;
     }
     // End patch
   }