From 14093caf42d02d56cd32afa58bcbfc47b08fa50a Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Tue, 2 Nov 2021 11:56:07 +0200 Subject: [PATCH] Load image signature directly into a string --- source/graphics/imageloader.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/source/graphics/imageloader.cpp b/source/graphics/imageloader.cpp index e224af6..d2d3ef9 100644 --- a/source/graphics/imageloader.cpp +++ b/source/graphics/imageloader.cpp @@ -59,9 +59,8 @@ ImageLoader *ImageLoader::open_io(IO::Seekable &io) if(registry.loaders.empty()) throw unsupported_image_format("no loaders"); - vector sig_buf(registry.loaders.back()->get_signature_size()); - unsigned sig_len = io.read(&sig_buf[0], sig_buf.size()); - string signature(sig_buf.begin(), sig_buf.end()); + string signature(registry.loaders.back()->get_signature_size(), 0); + unsigned sig_len = io.read(&signature[0], signature.size()); ImageLoader *loader = 0; for(list::const_iterator i=registry.loaders.begin(); (!loader && i!=registry.loaders.end()); ++i) @@ -74,7 +73,7 @@ ImageLoader *ImageLoader::open_io(IO::Seekable &io) { string sig_hex; for(unsigned i=0; i(sig_buf[i]))); + append(sig_hex, " ", format("%02X", static_cast(signature[i]))); throw unsupported_image_format(sig_hex); } -- 2.43.0