Skip to content

Commit 97b71b8

Browse files
committed
Fix memleak in r2 setenv
1 parent 8fe3d51 commit 97b71b8

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

libr/main/radare2.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -721,11 +721,13 @@ R_API int r_main_radare2(int argc, const char **argv) {
721721
sigaddset (&sigBlockMask, SIGWINCH);
722722
r_signal_sigmask (SIG_BLOCK, &sigBlockMask, NULL);
723723
#endif
724-
725724
r_sys_env_init ();
726-
if (!r_sys_getenv("R2_BIN")) {
727-
r_sys_setenv("R2_BIN", R2_BINDIR);
728-
r_sys_setenv_sep("PATH", R2_BINDIR, false);
725+
char *r2_bin = r_sys_getenv ("R2_BIN");
726+
if (r2_bin) {
727+
free (r2_bin);
728+
} else {
729+
r_sys_setenv ("R2_BIN", R2_BINDIR);
730+
r_sys_setenv_sep ("PATH", R2_BINDIR, false);
729731
}
730732
// Create rarun2 profile with startup environ
731733
char **env = r_sys_get_environ ();

0 commit comments

Comments
 (0)