Skip to content

Commit

Permalink
Fix #141 - double free bug in SleighAsm, crashing only on Windows
Browse files Browse the repository at this point in the history
* std::string behaves different depending on char* char[] and const char*
  • Loading branch information
radare committed Jul 14, 2024
1 parent a167eaf commit 11d3ba7
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/SleighAsm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ RConfig *SleighAsm::getConfig(RAnal *a) {
return core->config;
}

std::string SleighAsm::getSleighHome(RConfig *cfg) {
std::string SleighAsm::getSleighHome(R_NULLABLE RConfig *cfg) {
const char varname[] = "r2ghidra.sleighhome";
char *path = nullptr;

Expand All @@ -419,7 +419,6 @@ std::string SleighAsm::getSleighHome(RConfig *cfg) {
r_config_set (cfg, varname, ev);
}
std::string res (ev);
free (ev);
return res;
}

Expand All @@ -435,7 +434,6 @@ std::string SleighAsm::getSleighHome(RConfig *cfg) {
r_config_set (cfg, varname, path);
}
std::string res (path);
free ((void *)path);
return res;
}
free ((void *)path);
Expand All @@ -445,15 +443,15 @@ std::string SleighAsm::getSleighHome(RConfig *cfg) {
r_config_set (cfg, varname, path);
}
std::string res (path);
free ((void *)path);
return res;
} else {
#ifdef R2GHIDRA_SLEIGHHOME_DEFAULT
if (r_file_is_directory (R2GHIDRA_SLEIGHHOME_DEFAULT)) {
if (cfg) {
r_config_set (cfg, varname, R2GHIDRA_SLEIGHHOME_DEFAULT);
}
return R2GHIDRA_SLEIGHHOME_DEFAULT;
std::string res (R2GHIDRA_SLEIGHHOME_DEFAULT);
return res;
}
#endif
R_LOG_ERROR ("Cannot find the sleigh home at '%s'. Fix it with `r2pm -ci r2ghidra-sleigh`", path);
Expand Down

0 comments on commit 11d3ba7

Please sign in to comment.