Fix some bugs in projects ##projects
* Use r_file_is_directory * Return true instead of false in r_project_rename * Free core->prj->path before resetting it * Check for null in r_project_rename
This commit is contained in:
parent
4bef862bd2
commit
ac513ddc34
|
@ -15,16 +15,22 @@ R_API bool r_project_rename(RProject *p, const char *newname) {
|
|||
return false;
|
||||
}
|
||||
char *newprjdir = r_file_new (p->path, "..", newname, NULL);
|
||||
if (r_file_exists (newprjdir)) {
|
||||
if (r_file_is_directory (newprjdir)) {
|
||||
R_LOG_ERROR ("Cannot rename project");
|
||||
free (newprjdir);
|
||||
return false;
|
||||
}
|
||||
r_file_move (p->path, newprjdir);
|
||||
free (p->path);
|
||||
p->path = newprjdir;
|
||||
free (p->name);
|
||||
p->name = strdup (newname);
|
||||
if (r_file_move (p->path, newprjdir)) {
|
||||
char *new_name = strdup (newname);
|
||||
if (new_name) {
|
||||
free (p->path);
|
||||
free (p->name);
|
||||
p->path = newprjdir;
|
||||
p->name = new_name;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
free (newprjdir);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -737,7 +737,8 @@ R_API bool r_core_project_save(RCore *core, const char *prj_name) {
|
|||
free (cwd);
|
||||
}
|
||||
// LEAK : not always in heap free (prj_name);
|
||||
free (prj_dir);
|
||||
free (core->prj->path);
|
||||
core->prj->path = prj_dir;
|
||||
if (scr_null) {
|
||||
r_config_set_b (core->config, "scr.null", true);
|
||||
}
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Subproject commit a3ea888e318b8b841de6333e0663d649db2f8d36
|
Loading…
Reference in New Issue