Replace VLA by dynamic allocation
And increase the command buffer size. Refs #1358 <https://github.com/Genymobile/scrcpy/issues/1358#issuecomment-862989748> PR #2405 <https://github.com/Genymobile/scrcpy/pull/2405> Signed-off-by: Romain Vimont <rom@rom1v.com>
This commit is contained in:
committed by
Romain Vimont
parent
fda32928c1
commit
a9d9cbf8b5
@@ -6,6 +6,8 @@
|
||||
#include "util/log.h"
|
||||
#include "util/str_util.h"
|
||||
|
||||
#define CMD_MAX_LEN 8192
|
||||
|
||||
static bool
|
||||
build_cmd(char *cmd, size_t len, const char *const argv[]) {
|
||||
// Windows command-line parsing is WTF:
|
||||
@@ -27,13 +29,14 @@ process_execute(const char *const argv[], HANDLE *handle) {
|
||||
memset(&si, 0, sizeof(si));
|
||||
si.cb = sizeof(si);
|
||||
|
||||
char cmd[256];
|
||||
if (!build_cmd(cmd, sizeof(cmd), argv)) {
|
||||
char *cmd = malloc(CMD_MAX_LEN);
|
||||
if (!cmd || !build_cmd(cmd, CMD_MAX_LEN, argv)) {
|
||||
*handle = NULL;
|
||||
return PROCESS_ERROR_GENERIC;
|
||||
}
|
||||
|
||||
wchar_t *wide = utf8_to_wide_char(cmd);
|
||||
free(cmd);
|
||||
if (!wide) {
|
||||
LOGC("Could not allocate wide char string");
|
||||
return PROCESS_ERROR_GENERIC;
|
||||
|
||||
Reference in New Issue
Block a user