lib/crypto/Base64: add overload which returns AllocatedArray<std::byte>

This commit is contained in:
Max Kellermann
2022-05-24 14:26:59 +02:00
parent 3699514d18
commit 3dd2434149
3 changed files with 22 additions and 12 deletions

View File

@@ -20,11 +20,9 @@
#include "VorbisPicture.hxx"
#include "lib/crypto/Base64.hxx"
#include "tag/Id3Picture.hxx"
#include "tag/Handler.hxx"
#include "util/AllocatedArray.hxx"
#include "config.h"
#include <memory>
void
ScanVorbisPicture(std::string_view value, TagHandler &handler) noexcept
{
@@ -33,19 +31,11 @@ ScanVorbisPicture(std::string_view value, TagHandler &handler) noexcept
/* ignore image files which are too huge */
return;
size_t debase64_size = CalculateBase64OutputSize(value.size());
auto debase64_buffer = std::make_unique<std::byte[]>(debase64_size);
try {
debase64_size =
DecodeBase64({debase64_buffer.get(), debase64_size},
value);
return ScanId3Apic(DecodeBase64(value), handler);
} catch (...) {
// TODO: log?
return;
}
return ScanId3Apic({debase64_buffer.get(), debase64_size}, handler);
#else
(void)value;
(void)handler;