-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set prj.name before saving a project to save that value correctly #7485
Conversation
libr/core/cmd_project.c
Outdated
@@ -57,9 +57,12 @@ static int cmd_project(void *data, const char *input) { | |||
if (!file || !file[0]) { /* if no argument specified use current project */ | |||
file = str; | |||
} | |||
r_config_set (core->config, "prj.name", file); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This var should be set inside project_save maybe, so you can remove all that logic from here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. I moved it inside r_core_project_save.
// reset prj.name on fail | ||
r_config_set (core->config, "prj.name", oldPrjName); | ||
} | ||
free(oldPrjName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing space
@@ -706,6 +713,11 @@ R_API bool r_core_project_save(RCore *core, const char *prjName) { | |||
if (scr_null) { | |||
r_config_set_i (core->config, "scr.null", true); | |||
} | |||
if (!ret) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
&& oldPrjName
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should also reset it if oldPrjName is NULL. Or is it not allowed to do r_config_set (core->config, "prj.name", 0)? In that case it should probably be set to "".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in theory it should never be null unless strdup fails. right?
Thanks! |
Goes along with https://github.com/radare/radare2-regressions/pull/843
prj.name should be set before saving the project, so it will be correct in the project file.
The resetting if the save fails is not beatiful, but I don't really know a better way in this case.