Fix issues on ARM builds (#2205)
* Specify base class initialization in Copy Constructor * Fix printing of uint64_t variable in ARM 32bits Use cinttypes * Fix alignment issues on ARM 32 bits * tests: add assertion with custom message
This commit is contained in:
parent
6203ded16f
commit
941017d281
@ -16,6 +16,7 @@
|
||||
#include "types.hpp"
|
||||
|
||||
// + standard includes
|
||||
#include <cinttypes>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
@ -184,7 +185,7 @@ long BmffImage::boxHandler(std::ostream& out /* = std::cout*/, Exiv2::PrintStruc
|
||||
if (bTrace) {
|
||||
bLF = true;
|
||||
out << indent(depth) << "Exiv2::BmffImage::boxHandler: " << toAscii(box_type)
|
||||
<< Internal::stringFormat(" %8ld->%lu ", address, box_length);
|
||||
<< Internal::stringFormat(" %8ld->%" PRIu64 " ", address, box_length);
|
||||
}
|
||||
|
||||
if (box_length == 1) {
|
||||
|
||||
@ -508,7 +508,7 @@ IptcKey::IptcKey(uint16_t tag, uint16_t record) : tag_(tag), record_(record) {
|
||||
makeKey();
|
||||
}
|
||||
|
||||
IptcKey::IptcKey(const IptcKey& rhs) : tag_(rhs.tag_), record_(rhs.record_), key_(rhs.key_) {
|
||||
IptcKey::IptcKey(const IptcKey& rhs) : Key(), tag_(rhs.tag_), record_(rhs.record_), key_(rhs.key_) {
|
||||
}
|
||||
|
||||
std::string IptcKey::key() const {
|
||||
|
||||
@ -604,25 +604,20 @@ void Jp2Image::encodeJp2Header(const DataBuf& boxBuf, DataBuf& outBuf) {
|
||||
size_t outlen = boxHSize; // now many bytes have we written to output?
|
||||
size_t inlen = boxHSize; // how many bytes have we read from boxBuf?
|
||||
enforce(boxHSize <= output.size(), ErrorCode::kerCorruptedMetadata);
|
||||
auto pBox = reinterpret_cast<const Internal::Jp2BoxHeader*>(boxBuf.c_data());
|
||||
uint32_t length = getLong(reinterpret_cast<const byte*>(&pBox->length), bigEndian);
|
||||
uint32_t length = getLong(boxBuf.c_data(0), bigEndian);
|
||||
enforce(length <= output.size(), ErrorCode::kerCorruptedMetadata);
|
||||
uint32_t count = boxHSize;
|
||||
auto p = boxBuf.c_str();
|
||||
bool bWroteColor = false;
|
||||
|
||||
while (count < length && !bWroteColor) {
|
||||
enforce(boxHSize <= length - count, ErrorCode::kerCorruptedMetadata);
|
||||
auto pSubBox = reinterpret_cast<const Internal::Jp2BoxHeader*>(p + count);
|
||||
|
||||
// copy data. pointer could be into a memory mapped file which we will decode!
|
||||
Internal::Jp2BoxHeader subBox;
|
||||
memcpy(&subBox, pSubBox, boxHSize);
|
||||
memcpy(&subBox, boxBuf.c_data(count), boxHSize);
|
||||
Internal::Jp2BoxHeader newBox = subBox;
|
||||
|
||||
if (count < length) {
|
||||
subBox.length = getLong(reinterpret_cast<byte*>(&subBox.length), bigEndian);
|
||||
subBox.type = getLong(reinterpret_cast<byte*>(&subBox.type), bigEndian);
|
||||
subBox.length = getLong(boxBuf.c_data(count), bigEndian);
|
||||
subBox.type = getLong(boxBuf.c_data(count + 4), bigEndian);
|
||||
#ifdef EXIV2_DEBUG_MESSAGES
|
||||
std::cout << "Jp2Image::encodeJp2Header subbox: " << toAscii(subBox.type) << " length = " << subBox.length
|
||||
<< std::endl;
|
||||
@ -671,9 +666,8 @@ void Jp2Image::encodeJp2Header(const DataBuf& boxBuf, DataBuf& outBuf) {
|
||||
// allocate the correct number of bytes, copy the data and update the box header
|
||||
outBuf.alloc(outlen);
|
||||
std::copy_n(output.c_data(), outlen, outBuf.begin());
|
||||
auto oBox = reinterpret_cast<Internal::Jp2BoxHeader*>(outBuf.data());
|
||||
ul2Data(reinterpret_cast<byte*>(&oBox->type), kJp2BoxTypeHeader, bigEndian);
|
||||
ul2Data(reinterpret_cast<byte*>(&oBox->length), static_cast<uint32_t>(outlen), bigEndian);
|
||||
ul2Data(outBuf.data(0), static_cast<uint32_t>(outlen), bigEndian);
|
||||
ul2Data(outBuf.data(4), kJp2BoxTypeHeader, bigEndian);
|
||||
}
|
||||
|
||||
#ifdef __clang__
|
||||
|
||||
@ -5097,7 +5097,7 @@ XmpKey::XmpKey(const std::string& prefix, const std::string& property) : p_(std:
|
||||
|
||||
XmpKey::~XmpKey() = default;
|
||||
|
||||
XmpKey::XmpKey(const XmpKey& rhs) : p_(std::make_unique<Impl>(*rhs.p_)) {
|
||||
XmpKey::XmpKey(const XmpKey& rhs) : Key(), p_(std::make_unique<Impl>(*rhs.p_)) {
|
||||
}
|
||||
|
||||
XmpKey& XmpKey::operator=(const XmpKey& rhs) {
|
||||
|
||||
@ -266,7 +266,7 @@ ExifKey::ExifKey(const std::string& key) : p_(std::make_unique<Impl>()) {
|
||||
p_->decomposeKey(key);
|
||||
}
|
||||
|
||||
ExifKey::ExifKey(const ExifKey& rhs) : p_(std::make_unique<Impl>(*rhs.p_)) {
|
||||
ExifKey::ExifKey(const ExifKey& rhs) : Key(), p_(std::make_unique<Impl>(*rhs.p_)) {
|
||||
}
|
||||
|
||||
ExifKey::~ExifKey() = default;
|
||||
|
||||
@ -484,6 +484,7 @@ set Exif.Photo.DateTimeDigitized 2020:05:26 07:31:42
|
||||
BT.copyTestFile('large.icc', iccname)
|
||||
out += BT.Executer('exiv2 -iC {img}', vars())
|
||||
e = BT.Executer('exiv2 -pC {img}', vars(), compatible_output=False, decode_output=False)
|
||||
self.assertIsNotNone(e.stdout, msg="Empty ICC profile in {}".format(img))
|
||||
BT.save(e.stdout, stub + '_large_1.icc')
|
||||
out += BT.Executer('exiv2 -pS {img}', vars())
|
||||
out += BT.Executer('exiv2 -eC --force {img}', vars())
|
||||
|
||||
Loading…
Reference in New Issue
Block a user