Skip to content

Commit

Permalink
replace lambda with function
Browse files Browse the repository at this point in the history
since we're going to longjmp out of this function, probably best to stay as trivial as possible
  • Loading branch information
spoonincode committed Mar 20, 2024
1 parent 4f9ef0e commit f725536
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions include/eosio/vm/signals.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,22 @@ namespace eosio { namespace vm {
template<int Sig>
inline struct sigaction prev_signal_handler;

inline void signal_handler(int sig, siginfo_t* info, void* uap) {
sigjmp_buf* dest = std::atomic_load(&signal_dest);
inline bool in_protected_range(void* addr) {
//empty protection list means legacy catch-all behavior; useful for some of the old tests
if(protected_memory_ranges.empty())
return true;

auto in_protected_range = [&]() {
//empty protection list means legacy catch-all behavior; useful for some of the old tests
if(protected_memory_ranges.empty())
for(const std::span<std::byte>& range : protected_memory_ranges) {
if(addr >= range.data() && addr < range.data() + range.size())
return true;
}
return false;
}

for(const std::span<std::byte>& range : protected_memory_ranges) {
if(info->si_addr >= range.data() && info->si_addr < range.data() + range.size())
return true;
}
return false;
};
inline void signal_handler(int sig, siginfo_t* info, void* uap) {
sigjmp_buf* dest = std::atomic_load(&signal_dest);

if (dest && in_protected_range()) {
if (dest && in_protected_range(info->si_addr)) {
siglongjmp(*dest, sig);
} else {
struct sigaction* prev_action;
Expand Down

0 comments on commit f725536

Please sign in to comment.