std::string(char*) crashes if it's given a nullptr.

This commit is contained in:
John Ralls 2021-08-05 15:41:03 -07:00
parent b6622a386b
commit f0ecc0e2eb

View File

@ -2320,8 +2320,11 @@ public:
{
auto string = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(get_widget()));
DEBUG("filename %s", string ? string : "(null)");
option.set_value(std::string{string});
g_free(string);
if (string)
{
option.set_value(std::string{string});
g_free(string);
}
}
};