summaryrefslogtreecommitdiff
path: root/src/Fl_Native_File_Chooser_Kdialog.cxx
diff options
context:
space:
mode:
authorManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2023-01-31 17:01:30 +0100
committerManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2023-01-31 17:01:30 +0100
commit8ef592db1e63401d3972bef6caf8290a2e3f865e (patch)
treece2eb17f46b8743b6d8027bae9bcf6744f35470c /src/Fl_Native_File_Chooser_Kdialog.cxx
parentf75f05e7b7235a75db161b6a4bd5ee07450c6034 (diff)
Fix crash in Zenity filechooser with badly formed filter (#665)
Diffstat (limited to 'src/Fl_Native_File_Chooser_Kdialog.cxx')
-rw-r--r--src/Fl_Native_File_Chooser_Kdialog.cxx13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/Fl_Native_File_Chooser_Kdialog.cxx b/src/Fl_Native_File_Chooser_Kdialog.cxx
index 6fc27f1ec..a89a74abc 100644
--- a/src/Fl_Native_File_Chooser_Kdialog.cxx
+++ b/src/Fl_Native_File_Chooser_Kdialog.cxx
@@ -208,7 +208,7 @@ char *Fl_Kdialog_Native_File_Chooser_Driver::parse_filter(const char *f) {
char *lead = new char[r-p];
memcpy(lead, p+1, (r-p)-1); lead[(r-p)-1] = 0;
const char *r2 = strchr(r, '}');
- if (!r2) return NULL;
+ if (!r2 || r2 == r + 1) return NULL;
char *ends = new char[r2-r];
memcpy(ends, r+1, (r2-r)-1); ends[(r2-r)-1] = 0;
char *ptr;
@@ -249,11 +249,12 @@ void Fl_Kdialog_Native_File_Chooser_Driver::filter(const char *f) {
char *part = strtok_r(f2, "\n", &ptr);
while (part) {
char *p = parse_filter(part);
- if (!p) break;
- _parsedfilt = strapp(_parsedfilt, p);
- _parsedfilt = strapp(_parsedfilt, "\n");
- delete[] p;
- _nfilters++;
+ if (p) {
+ _parsedfilt = strapp(_parsedfilt, p);
+ _parsedfilt = strapp(_parsedfilt, "\n");
+ delete[] p;
+ _nfilters++;
+ }
part = strtok_r(NULL, "\n", &ptr);
}
free(f2);