mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-10-04 21:29:21 +00:00
Use heap allocated buffer for rpc::ExecFile::execute_object() and increase size to 128Kb.
This commit is contained in:
committed by
Jari Sundell
parent
3af0410a6e
commit
66c49d24e5
@@ -1,5 +1,7 @@
|
||||
#include "config.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "rpc/exec_file.h"
|
||||
|
||||
// #include <cassert>
|
||||
@@ -81,8 +83,9 @@ ExecFile::execute_object(const torrent::Object& rawArgs, int flags) {
|
||||
char* argsBuffer[max_args];
|
||||
char** argsCurrent = argsBuffer;
|
||||
|
||||
// Size of value strings are less than 24.
|
||||
char valueBuffer[buffer_size+1];
|
||||
// On the heap: a buffer of buffer_size does not belong on the stack of whichever thread runs the command.
|
||||
auto valueStorage = std::make_unique<char[]>(buffer_size + 1);
|
||||
char* valueBuffer = valueStorage.get();
|
||||
char* valueCurrent = valueBuffer;
|
||||
|
||||
if (rawArgs.is_list()) {
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@ namespace rpc {
|
||||
class ExecFile {
|
||||
public:
|
||||
static constexpr unsigned int max_args = 128;
|
||||
static constexpr unsigned int buffer_size = 4096;
|
||||
static constexpr unsigned int buffer_size = 128 * 1024;
|
||||
|
||||
static constexpr int flag_expand_tilde = 0x1;
|
||||
static constexpr int flag_throw = 0x2;
|
||||
|
||||
Reference in New Issue
Block a user