Skip to content

Commit

Permalink
hl2_launcher_linux: be pedantic
Browse files Browse the repository at this point in the history
  • Loading branch information
darealshinji authored Jul 18, 2019
1 parent 1e4e134 commit a06257b
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions hl2_launcher_linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,28 @@ int main(int argc, char *argv[])
LauncherMain_t pLauncherMain;
int resultLauncherMain;

// get full executable path
if ((self = realpath("/proc/self/exe", NULL)) == NULL) {
perror("realpath()");
return 1;
}

dn = dirname(self);
free(self);
// get directory name
if ((dn = dirname(self)) == NULL) {
fprintf(stderr, "error: dirname() returned NULL\n");
free(self);
return 1;
}

// change directory
if (chdir(dn) != 0) {
perror("chdir()");
free(self);
return 1;
}

dn = NULL;
free(self);

if ((hinstLauncher = dlopen("./bin/launcher.so", RTLD_LAZY)) == NULL) {
fprintf(stderr, "error: %s\n", dlerror());
Expand Down

0 comments on commit a06257b

Please sign in to comment.