cinatra icon indicating copy to clipboard operation
cinatra copied to clipboard

set_http_handler函数参数和Map参数问题

Open 1647606255 opened this issue 4 years ago • 0 comments

void set_http_handler(std::string_view name, Function &&f, AP &&...ap) 这个函数的第一个参数是string_view ,当传入string类型作为路径 的时候。因为map的类型也是string_view ,导致入参析构的时候,有客户端请求,通过map去查找处理函数的时候。程序崩溃。这样风险很高。建议路由和处理函数map的时候使用string.

std::map<std::string_view, invoker_function> map_invokers_; std::unordered_map<std::string_view, invoker_function> wildcard_invokers_; // for url/*

1647606255 avatar Jun 28 '21 03:06 1647606255