plug
plug copied to clipboard
App crash on connection/library view
Hi, whenever the Plug tries to connect to my Fender Mustang I V2 it crashes with nothing on the output but the following error
/usr/include/c++/14.1.1/bits/stl_vector.h:1149: std::vector<_Tp, _Alloc>::const_reference std::vector<_Tp, _Alloc>::operator[](size_type) const [with _Tp = std::__cxx11::basic_string<char>; _Alloc = std::allocator<std::__cxx11::basic_string<char> >; const_reference = const std::__cxx11::basic_string<char>&; size_type = long unsigned int]: Assertion '__n < this->size()' failed.
Aborted (core dumped)
Same thing happens when I try to open the "Library View".
The culprit is in the functions load_names
in ui/library.cpp:54
, ui/loadfromamp.cpp:64
, ui/quickpresets.cpp:53
and ui/saveonamp.cpp:65
. All the functions try to load the input vector of effect names into a visual component and try to access elements beyond its actual size. The loop's upper limit is a hard-coded 100
instead of the actual size of the vector. The 100 is the capacity of the vector, however, and is set during its creation. I'm not sure if the constant is there on purpose, but my amp only has 24 effects so I can't use the app without fixing this. I did the following changes to the code
diff -ura plug.orig/src/ui/library.cpp plug.new/src/ui/library.cpp
--- plug.orig/src/ui/library.cpp 2023-12-05 20:25:19.000000000 +0100
+++ plug.new/src/ui/library.cpp 2024-09-12 19:30:45.053052939 +0200
@@ -51,7 +51,7 @@
ui->spinBox->setValue(font.pointSize());
ui->fontComboBox->setCurrentFont(font);
- for (std::size_t i = 0; i < 100; ++i)
+ for (std::size_t i = 0; i < names.size() && i < 100; ++i)
{
if (names[i][0] == 0x00)
{
diff -ura plug.orig/src/ui/loadfromamp.cpp plug.new/src/ui/loadfromamp.cpp
--- plug.orig/src/ui/loadfromamp.cpp 2023-12-05 20:25:19.000000000 +0100
+++ plug.new/src/ui/loadfromamp.cpp 2024-09-12 19:30:45.053052939 +0200
@@ -61,7 +61,7 @@
void LoadFromAmp::load_names(const std::vector<std::string>& names)
{
- for (std::size_t i = 0; i < 100; ++i)
+ for (std::size_t i = 0; i < names.size() && i < 100; ++i)
{
if (names[i][0] == 0x00)
{
diff -ura plug.orig/src/ui/quickpresets.cpp plug.new/src/ui/quickpresets.cpp
--- plug.orig/src/ui/quickpresets.cpp 2023-12-05 20:25:19.000000000 +0100
+++ plug.new/src/ui/quickpresets.cpp 2024-09-12 19:30:45.053052939 +0200
@@ -50,7 +50,7 @@
QSettings settings;
std::size_t i = 0;
- for (i = 0; i < 100; i++)
+ for (i = 0; i < names.size() && i < 100; ++i)
{
if (names[i][0] == 0x00)
{
diff -ura plug.orig/src/ui/saveonamp.cpp plug.new/src/ui/saveonamp.cpp
--- plug.orig/src/ui/saveonamp.cpp 2023-12-05 20:25:19.000000000 +0100
+++ plug.new/src/ui/saveonamp.cpp 2024-09-12 19:30:45.053052939 +0200
@@ -62,7 +62,7 @@
void SaveOnAmp::load_names(const std::vector<std::string>& names)
{
- for (std::size_t i = 0; i < 100; ++i)
+ for (std::size_t i = 0; i < names.size() && i < 100; ++i)
{
if (names[i][0] == 0x00)
{
Thank you for resolving this issue.
PS: Thanks for this project! I'm glad I can use the amp with linux.