We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Describe the bug (描述bug) The default ServerOptions _options of Server may leak since it will be covered by user's ServerOptions.
_options
To Reproduce (复现方法)
ServerOptions::ServerOptions() : .... , rpc_pb_message_factory(new DefaultRpcPBMessageFactory()) // BAD: New here, but delete elsewhere , ... { // ... } class Server { public: // ... ServerOptions _options; // ... ~Server() { //... delete _options.rpc_pb_message_factory; // <--- BAD: only the last '_options' will free rpc_pb_message_factory _options.rpc_pb_message_factory = NULL; //... } }; int Server::Start(const butil::EndPoint& endpoint, const ServerOptions* opt) { return StartInternal( endpoint, PortRange(endpoint.port, endpoint.port), opt); } int Server::StartInternal(const butil::EndPoint& endpoint, const PortRange& port_range, const ServerOptions *opt) { // ... if (opt) { _options = *opt; // <----- LEAK: _options.rpc_pb_message_factory miss free } else { // Always reset to default options explicitly since `_options' // may be the options for the last run or even bad options _options = ServerOptions(); // <----- LEAK: _options.rpc_pb_message_factory miss free } // ... }
Expected behavior (期望行为) No memory leak, pls.
Versions (各种版本) OS: Compiler: brpc: protobuf:
Additional context/screenshots (更多上下文/截图)
The text was updated successfully, but these errors were encountered:
@chenBright
Sorry, something went wrong.
Successfully merging a pull request may close this issue.
Describe the bug (描述bug)
The default ServerOptions
_options
of Server may leak since it will be covered by user's ServerOptions.To Reproduce (复现方法)
Expected behavior (期望行为)
No memory leak, pls.
Versions (各种版本)
OS:
Compiler:
brpc:
protobuf:
Additional context/screenshots (更多上下文/截图)
The text was updated successfully, but these errors were encountered: