Skip to content

Commit d6c48c6

Browse files
committed
Fix renderdoccmd -c on Linux
* argv[0] should always be set up * log an error when execve fails * logfile is always NULL and constructing a std::string from NULL throws * really apply EnvironmentModification
1 parent 7aa561c commit d6c48c6

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

renderdoc/os/linux/linux_process.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,16 +83,16 @@ static pid_t RunProcess(const char *app, const char *workingDir, const char *cmd
8383
{
8484
if(!app) return (pid_t)0;
8585

86-
int argc = 0;
87-
char *emptyargv[] = { NULL };
86+
// it is safe to use app directly as execve never modifies argv
87+
char *emptyargv[] = { (char *) app, NULL };
8888
char **argv = emptyargv;
8989

9090
const char *c = cmdLine;
9191

9292
// parse command line into argv[], similar to how bash would
9393
if(cmdLine)
9494
{
95-
argc = 1;
95+
int argc = 1;
9696

9797
// get a rough upper bound on the number of arguments
9898
while(*c)
@@ -212,6 +212,7 @@ static pid_t RunProcess(const char *app, const char *workingDir, const char *cmd
212212
}
213213

214214
execve(app, argv, envp);
215+
RDCERR("Failed to execute %s: %s", app, strerror(errno));
215216
exit(0);
216217
}
217218

@@ -261,6 +262,9 @@ uint32_t Process::LaunchAndInjectIntoProcess(const char *app, const char *workin
261262
map<string, string> env = EnvStringToEnvMap((const char **)environ);
262263
vector<EnvironmentModification> &modifications = GetEnvModifications();
263264

265+
if (logfile == NULL)
266+
logfile = "";
267+
264268
string libpath;
265269
{
266270
FileIO::GetExecutableFilename(libpath);
@@ -287,7 +291,7 @@ uint32_t Process::LaunchAndInjectIntoProcess(const char *app, const char *workin
287291
{
288292
EnvironmentModification &m = modifications[i];
289293

290-
string value = env[m.name];
294+
string &value = env[m.name];
291295

292296
switch(m.type)
293297
{

0 commit comments

Comments
 (0)