File: ots-lz4.patch

package info (click to toggle)
firefox 147.0.4-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 4,683,532 kB
  • sloc: cpp: 7,607,356; javascript: 6,533,348; ansic: 3,775,236; python: 1,415,508; xml: 634,561; asm: 438,949; java: 186,241; sh: 62,760; makefile: 18,079; objc: 13,092; perl: 12,808; yacc: 4,583; cs: 3,846; pascal: 3,448; lex: 1,720; ruby: 1,003; php: 436; lisp: 258; awk: 247; sql: 66; sed: 54; csh: 10; exp: 6
file content (104 lines) | stat: -rw-r--r-- 4,290 bytes parent folder | download | duplicates (12)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
diff --git a/src/glat.cc b/src/glat.cc
--- a/src/glat.cc
+++ b/src/glat.cc
@@ -1,16 +1,16 @@
 // Copyright (c) 2009-2017 The OTS Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
 #include "glat.h"
 
 #include "gloc.h"
-#include "lz4.h"
+#include "mozilla/Compression.h"
 #include <list>
 #include <memory>
 
 namespace ots {
 
 // -----------------------------------------------------------------------------
 // OpenTypeGLAT_v1
 // -----------------------------------------------------------------------------
@@ -212,24 +212,25 @@ bool OpenTypeGLAT_v3::Parse(const uint8_
       }
       // decompressed table must be <= OTS_MAX_DECOMPRESSED_TABLE_SIZE
       if (decompressed_size > OTS_MAX_DECOMPRESSED_TABLE_SIZE) {
         return DropGraphite("Decompressed size exceeds %gMB: %gMB",
                             OTS_MAX_DECOMPRESSED_TABLE_SIZE / (1024.0 * 1024.0),
                             decompressed_size / (1024.0 * 1024.0));
       }
       std::unique_ptr<uint8_t> decompressed(new uint8_t[decompressed_size]());
-      int ret = LZ4_decompress_safe_partial(
+      size_t outputSize = 0;
+      bool ret = mozilla::Compression::LZ4::decompressPartial(
           reinterpret_cast<const char*>(data + table.offset()),
-          reinterpret_cast<char*>(decompressed.get()),
           table.remaining(),  // input buffer size (input size + padding)
+          reinterpret_cast<char*>(decompressed.get()),
           decompressed_size,  // target output size
-          decompressed_size);  // output buffer size
-      if (ret < 0 || unsigned(ret) != decompressed_size) {
-        return DropGraphite("Decompression failed with error code %d", ret);
+          &outputSize);  // return output size
+      if (!ret || outputSize != decompressed_size) {
+        return DropGraphite("Decompression failed");
       }
       return this->Parse(decompressed.get(), decompressed_size, true);
     }
     default:
       return DropGraphite("Unknown compression scheme");
   }
   if (this->compHead & RESERVED) {
     Warning("Nonzero reserved");
diff --git a/src/silf.cc b/src/silf.cc
--- a/src/silf.cc
+++ b/src/silf.cc
@@ -1,16 +1,16 @@
 // Copyright (c) 2009-2017 The OTS Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
 #include "silf.h"
 
 #include "name.h"
-#include "lz4.h"
+#include "mozilla/Compression.h"
 #include <cmath>
 #include <memory>
 
 namespace ots {
 
 bool OpenTypeSILF::Parse(const uint8_t* data, size_t length,
                          bool prevent_decompression) {
   Buffer table(data, length);
@@ -45,24 +45,25 @@ bool OpenTypeSILF::Parse(const uint8_t* 
         }
         // decompressed table must be <= OTS_MAX_DECOMPRESSED_TABLE_SIZE
         if (decompressed_size > OTS_MAX_DECOMPRESSED_TABLE_SIZE) {
           return DropGraphite("Decompressed size exceeds %gMB: %gMB",
                               OTS_MAX_DECOMPRESSED_TABLE_SIZE / (1024.0 * 1024.0),
                               decompressed_size / (1024.0 * 1024.0));
         }
         std::unique_ptr<uint8_t> decompressed(new uint8_t[decompressed_size]());
-        int ret = LZ4_decompress_safe_partial(
+        size_t outputSize = 0;
+        bool ret = mozilla::Compression::LZ4::decompressPartial(
             reinterpret_cast<const char*>(data + table.offset()),
-            reinterpret_cast<char*>(decompressed.get()),
             table.remaining(),  // input buffer size (input size + padding)
+            reinterpret_cast<char*>(decompressed.get()),
             decompressed_size,  // target output size
-            decompressed_size);  // output buffer size
-        if (ret < 0 || unsigned(ret) != decompressed_size) {
-          return DropGraphite("Decompression failed with error code %d", ret);
+            &outputSize);   // return output size
+        if (!ret || outputSize != decompressed_size) {
+          return DropGraphite("Decompression failed");
         }
         return this->Parse(decompressed.get(), decompressed_size, true);
       }
       default:
         return DropGraphite("Unknown compression scheme");
     }
   }
   if (!table.ReadU16(&this->numSub)) {