On 2017-05-10 03:10 PM, Benjamin Bales wrote:
CodeAi (https://github.com/C0deAi), an automated repair tool developed at QbitLogic (www.qbitlogic.com), suggested the following fix. Could I submit it as a patch if it looks alright?
plugins/saveactions.c: “doc->file_type” pointer might be dereferenced when null on line 283. Initialization may be provided by “doc” passed in as a function argument, but a null check would be prudent just in case. The fix checks “doc->file_type” for null before allowing a dereference on the following line. A snapshot of the bug report generated by CodeAi is attached. A full report is available upon request.
diff --git a/plugins/saveactions.c b/plugins/saveactions.c
@@ -280,8 +280,10 @@ static void instantsave_document_new_cb(GObject *obj, GeanyDocument *doc, gpoint
doc->file_name = new_filename;
- if (doc->file_type->id == GEANY_FILETYPES_NONE)
if(doc->file_type) {
if (doc->file_type->id == GEANY_FILETYPES_NONE)
document_set_filetype(doc,
filetypes_lookup_by_name(instantsave_default_ft));
}
/* force saving the file to enable all the related actions(tab name,
filetype, etc.) */
document_save_file(doc, TRUE);
/* force saving the file to enable all the related actions(tab name, filetype, etc.) */
document_save_file(doc, TRUE);
}
}
Base-commit: 84253714771f48dbc7fab02f7de43f253734dee2
Please let me know if you are interested in seeing more fixes from our tool. Thanks!
Hi,
You can submit pull requests with properly formatted changes on Github. We've had a few PRs like these where analysis tools were run over the codebase and found issues (ex. see PR #166 & #186). If there are multiple trivial changes, it's probably fine to put it all in one PR as separate commits.
Regards, Matthew Brush