1 diff --git a/src/glat.cc b/src/glat.cc
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.
13 +#include "mozilla/Compression.h"
19 // -----------------------------------------------------------------------------
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);
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
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.
65 +#include "mozilla/Compression.h"
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);
101 return DropGraphite("Unknown compression scheme");
104 if (!table.ReadU16(&this->numSub)) {