ots-lz4.patch 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. diff --git a/gfx/ots/src/glat.cc b/gfx/ots/src/glat.cc
  2. --- a/gfx/ots/src/glat.cc
  3. +++ b/gfx/ots/src/glat.cc
  4. @@ -4,9 +4,9 @@
  5. #include "glat.h"
  6. #include "gloc.h"
  7. -#include "lz4.h"
  8. +#include "mozilla/Compression.h"
  9. #include <list>
  10. namespace ots {
  11. @@ -212,16 +212,17 @@ bool OpenTypeGLAT_v3::Parse(const uint8_
  12. return DropGraphite("Decompressed size exceeds 30MB: %gMB",
  13. decompressed_size / (1024.0 * 1024.0));
  14. }
  15. std::vector<uint8_t> decompressed(decompressed_size);
  16. - int ret = LZ4_decompress_safe_partial(
  17. + size_t outputSize = 0;
  18. + bool ret = mozilla::Compression::LZ4::decompressPartial(
  19. reinterpret_cast<const char*>(data + table.offset()),
  20. - reinterpret_cast<char*>(decompressed.data()),
  21. table.remaining(), // input buffer size (input size + padding)
  22. + reinterpret_cast<char*>(decompressed.data()),
  23. decompressed.size(), // target output size
  24. - decompressed.size()); // output buffer size
  25. - if (ret < 0 || unsigned(ret) != decompressed.size()) {
  26. - return DropGraphite("Decompression failed with error code %d", ret);
  27. + &outputSize); // return output size
  28. + if (!ret || outputSize != decompressed.size()) {
  29. + return DropGraphite("Decompression failed");
  30. }
  31. return this->Parse(decompressed.data(), decompressed.size(), true);
  32. }
  33. default:
  34. diff --git a/gfx/ots/src/silf.cc b/gfx/ots/src/silf.cc
  35. --- a/gfx/ots/src/silf.cc
  36. +++ b/gfx/ots/src/silf.cc
  37. @@ -4,9 +4,9 @@
  38. #include "silf.h"
  39. #include "name.h"
  40. -#include "lz4.h"
  41. +#include "mozilla/Compression.h"
  42. #include <cmath>
  43. namespace ots {
  44. @@ -50,16 +50,17 @@ bool OpenTypeSILF::Parse(const uint8_t*
  45. return DropGraphite("Decompressed size exceeds 30MB: %gMB",
  46. decompressed_size / (1024.0 * 1024.0));
  47. }
  48. std::vector<uint8_t> decompressed(decompressed_size);
  49. - int ret = LZ4_decompress_safe_partial(
  50. + size_t outputSize = 0;
  51. + bool ret = mozilla::Compression::LZ4::decompressPartial(
  52. reinterpret_cast<const char*>(data + table.offset()),
  53. - reinterpret_cast<char*>(decompressed.data()),
  54. table.remaining(), // input buffer size (input size + padding)
  55. + reinterpret_cast<char*>(decompressed.data()),
  56. decompressed.size(), // target output size
  57. - decompressed.size()); // output buffer size
  58. - if (ret < 0 || unsigned(ret) != decompressed.size()) {
  59. - return DropGraphite("Decompression failed with error code %d", ret);
  60. + &outputSize); // return output size
  61. + if (!ret || outputSize != decompressed.size()) {
  62. + return DropGraphite("Decompression failed");
  63. }
  64. return this->Parse(decompressed.data(), decompressed.size(), true);
  65. }
  66. default: