Backed out changeset 9d8b4c0b99ed (bug 1945683) for causing btime failures. CLOSED...
[gecko.git] / gfx / ots / ots-lz4.patch
blobff0041dbd5fd5065a391af91ae10435791ab492a
1 diff --git a/src/glat.cc b/src/glat.cc
2 --- a/src/glat.cc
3 +++ b/src/glat.cc
4 @@ -1,16 +1,16 @@
5 // Copyright (c) 2009-2017 The OTS Authors. All rights reserved.
6 // Use of this source code is governed by a BSD-style license that can be
7 // found in the LICENSE file.
9 #include "glat.h"
11 #include "gloc.h"
12 -#include "lz4.h"
13 +#include "mozilla/Compression.h"
14 #include <list>
15 #include <memory>
17 namespace ots {
19 // -----------------------------------------------------------------------------
20 // OpenTypeGLAT_v1
21 // -----------------------------------------------------------------------------
22 @@ -212,24 +212,25 @@ bool OpenTypeGLAT_v3::Parse(const uint8_
24 // decompressed table must be <= OTS_MAX_DECOMPRESSED_TABLE_SIZE
25 if (decompressed_size > OTS_MAX_DECOMPRESSED_TABLE_SIZE) {
26 return DropGraphite("Decompressed size exceeds %gMB: %gMB",
27 OTS_MAX_DECOMPRESSED_TABLE_SIZE / (1024.0 * 1024.0),
28 decompressed_size / (1024.0 * 1024.0));
30 std::unique_ptr<uint8_t> decompressed(new uint8_t[decompressed_size]());
31 - int ret = LZ4_decompress_safe_partial(
32 + size_t outputSize = 0;
33 + bool ret = mozilla::Compression::LZ4::decompressPartial(
34 reinterpret_cast<const char*>(data + table.offset()),
35 - reinterpret_cast<char*>(decompressed.get()),
36 table.remaining(), // input buffer size (input size + padding)
37 + reinterpret_cast<char*>(decompressed.get()),
38 decompressed_size, // target output size
39 - decompressed_size); // output buffer size
40 - if (ret < 0 || unsigned(ret) != decompressed_size) {
41 - return DropGraphite("Decompression failed with error code %d", ret);
42 + &outputSize); // return output size
43 + if (!ret || outputSize != decompressed_size) {
44 + return DropGraphite("Decompression failed");
46 return this->Parse(decompressed.get(), decompressed_size, true);
48 default:
49 return DropGraphite("Unknown compression scheme");
51 if (this->compHead & RESERVED) {
52 Warning("Nonzero reserved");
53 diff --git a/src/silf.cc b/src/silf.cc
54 --- a/src/silf.cc
55 +++ b/src/silf.cc
56 @@ -1,16 +1,16 @@
57 // Copyright (c) 2009-2017 The OTS Authors. All rights reserved.
58 // Use of this source code is governed by a BSD-style license that can be
59 // found in the LICENSE file.
61 #include "silf.h"
63 #include "name.h"
64 -#include "lz4.h"
65 +#include "mozilla/Compression.h"
66 #include <cmath>
67 #include <memory>
69 namespace ots {
71 bool OpenTypeSILF::Parse(const uint8_t* data, size_t length,
72 bool prevent_decompression) {
73 Buffer table(data, length);
74 @@ -45,24 +45,25 @@ bool OpenTypeSILF::Parse(const uint8_t*
76 // decompressed table must be <= OTS_MAX_DECOMPRESSED_TABLE_SIZE
77 if (decompressed_size > OTS_MAX_DECOMPRESSED_TABLE_SIZE) {
78 return DropGraphite("Decompressed size exceeds %gMB: %gMB",
79 OTS_MAX_DECOMPRESSED_TABLE_SIZE / (1024.0 * 1024.0),
80 decompressed_size / (1024.0 * 1024.0));
82 std::unique_ptr<uint8_t> decompressed(new uint8_t[decompressed_size]());
83 - int ret = LZ4_decompress_safe_partial(
84 + size_t outputSize = 0;
85 + bool ret = mozilla::Compression::LZ4::decompressPartial(
86 reinterpret_cast<const char*>(data + table.offset()),
87 - reinterpret_cast<char*>(decompressed.get()),
88 table.remaining(), // input buffer size (input size + padding)
89 + reinterpret_cast<char*>(decompressed.get()),
90 decompressed_size, // target output size
91 - decompressed_size); // output buffer size
92 - if (ret < 0 || unsigned(ret) != decompressed_size) {
93 - return DropGraphite("Decompression failed with error code %d", ret);
94 + &outputSize); // return output size
95 + if (!ret || outputSize != decompressed_size) {
96 + return DropGraphite("Decompression failed");
98 return this->Parse(decompressed.get(), decompressed_size, true);
100 default:
101 return DropGraphite("Unknown compression scheme");
104 if (!table.ReadU16(&this->numSub)) {