Skip to content
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

Merged
merged 2 commits into from
May 14, 2017

Conversation

thestr4ng3r
Copy link
Contributor

@thestr4ng3r thestr4ng3r commented May 13, 2017

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.

@@ -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);
Copy link
Collaborator

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

Copy link
Contributor Author

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);
Copy link
Collaborator

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) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

&& oldPrjName

Copy link
Contributor Author

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 "".

Copy link
Collaborator

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?

@radare radare merged commit 6e1595d into radareorg:master May 14, 2017
@radare
Copy link
Collaborator

radare commented May 14, 2017

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants