Skip to content

Commit

Permalink
Fix for the infinite loop on windows RCore.fileOpen ##crash
Browse files Browse the repository at this point in the history
  • Loading branch information
radare authored and trufae committed Apr 2, 2024
1 parent 09d3be2 commit f72b37c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,12 @@ jobs:
run: |
cd prefix\bin
radare2 -v
- name: Test executable again
# continue-on-error: true
shell: cmd
run: |
cd prefix\bin
radare2 -qc "?e Hello" -
w32-mingw:
if: contains(github.ref, 'master') || contains(github.ref, 'ci-')
name: w32-mingw
Expand Down
17 changes: 14 additions & 3 deletions libr/main/radare2.c
Original file line number Diff line number Diff line change
Expand Up @@ -1318,8 +1318,10 @@ R_API int r_main_radare2(int argc, const char **argv) {
#if R2__WINDOWS__
{
char *pfile = r_acp_to_utf8 (mr.pfile);
free (mr.pfile);
mr.pfile = pfile;
if (pfile != NULL) {
free (mr.pfile);
mr.pfile = pfile;
}
}
#endif
mr.fh = r_core_file_open (r, mr.pfile, mr.perms, mr.mapaddr);
Expand Down Expand Up @@ -1399,6 +1401,9 @@ R_API int r_main_radare2(int argc, const char **argv) {
}
#elif R2__WINDOWS__
char *acpfile = r_acp_to_utf8 (f);
if (!acpfile) {
acpfile = strdup (f);
}
// backslashes must be escaped because they are unscaped when parsing the uri
char *r = r_str_replace (acpfile, "\\", "\\\\", true);
if (r) {
Expand Down Expand Up @@ -1442,7 +1447,13 @@ R_API int r_main_radare2(int argc, const char **argv) {
while (opt.ind < argc) {
R_FREE (mr.pfile);
#if R2__WINDOWS__
mr.pfile = r_acp_to_utf8 (mr.pfile);
const char *argvi = argv[opt.ind++];
char *pfile = r_acp_to_utf8 (argvi);
if (pfile) {
mr.pfile = pfile;
} else {
mr.pfile = strdup (argvi);
}
#else
mr.pfile = strdup (argv[opt.ind++]);
#endif
Expand Down

0 comments on commit f72b37c

Please sign in to comment.