From 3b05c8976518fa2835e8c46bb6d6e6e099093ba2 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 6 Sep 2022 20:27:23 +0200 Subject: [PATCH] archive/iso9660: fix off-by-one assertion failure Calling data[fill] could trigger an assertion failure if fill==data.size(), even if we call it only to take the address. Instead of doing that, this commit changes the code to pointer arithmetic. Closes https://github.com/MusicPlayerDaemon/MPD/issues/1556 --- src/archive/plugins/Iso9660ArchivePlugin.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/archive/plugins/Iso9660ArchivePlugin.cxx b/src/archive/plugins/Iso9660ArchivePlugin.cxx index 7bcfb252a..375179970 100644 --- a/src/archive/plugins/Iso9660ArchivePlugin.cxx +++ b/src/archive/plugins/Iso9660ArchivePlugin.cxx @@ -166,7 +166,7 @@ class Iso9660InputStream final : public InputStream { assert(fill <= data.size()); assert(position <= fill); - return {&data[position], &data[fill]}; + return {data.data() + position, data.data() + fill}; } void Consume(size_t nbytes) noexcept {