diff --git a/src/aim1_mod_maker/aim1_mod_maker.h b/src/aim1_mod_maker/aim1_mod_maker.h index 1af085c..73805e5 100644 --- a/src/aim1_mod_maker/aim1_mod_maker.h +++ b/src/aim1_mod_maker/aim1_mod_maker.h @@ -178,9 +178,12 @@ struct bin_patcher { } v ^= value; } - static void replace_bin_in_file_raw(const path &fn, const std::string &from, const std::string &to) { + static void replace_bin_in_file_raw(const path &fn, const std::string &from, std::string to) { + if (to.size() > from.size()) { + throw std::runtime_error{"replacement string is larger than original"}; + } if (from.size() != to.size()) { - throw std::runtime_error{"mismatched size"}; + to.resize(from.size(), '\0'); } primitives::templates2::mmap_file f{fn, primitives::templates2::mmap_file::rw{}}; while (auto p = memmem(f.p, f.sz, from)) {