Fix #111355: Crash when calling operator 'TEXT_OT_save'

Crash occurs when calling with `EXEC_DEFAULT` context.

In this case `text->filepath` might be `nullptr` and cause a crash.

Fix by raising a Python error message in this case.
This commit is contained in:
Germano Cavalcante
2023-08-21 15:10:38 -03:00
parent 9269afda59
commit 5da64ff596

View File

@@ -607,6 +607,11 @@ static void txt_write_file(Main *bmain, Text *text, ReportList *reports)
BLI_stat_t st;
char filepath[FILE_MAX];
if (text->filepath == nullptr) {
BKE_reportf(reports, RPT_ERROR, "No file path for \"%s\"", text->id.name + 2);
return;
}
STRNCPY(filepath, text->filepath);
BLI_path_abs(filepath, BKE_main_blendfile_path(bmain));