Skip to content

Commit 6dfbcf3

Browse files
committed
fix segfault in file select extension filter
1 parent 2a4df05 commit 6dfbcf3

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/base/jwinfsel.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1080,8 +1080,9 @@ static int32_t fs_elist_proc(int32_t msg, DIALOG *d, int32_t c)
10801080
if((sel != d->d1) || (ret & D_CLOSE))
10811081
{
10821082
// change the extension(s)
1083-
fext = (char*) malloc(strlen(fext_list[d->d1].ext) + 1);
1084-
strcpy(fext, fext_list[d->d1].ext);
1083+
const char* ext2 = fext_list[d->d1].ext == NULL ? "" : fext_list[d->d1].ext;
1084+
fext = (char*) malloc(strlen(ext2) + 1);
1085+
strcpy(fext, ext2);
10851086
// if (fext)// && ugetc(fext))
10861087
{
10871088
parse_extension_string(fext);
@@ -1315,8 +1316,9 @@ int32_t jwin_file_browse_ex(AL_CONST char *message, char *path, EXT_LIST *list,
13151316
file_selector[FS_CANCEL].dp = (void*)get_config_text("Cancel");
13161317

13171318
fext_list = list;
1318-
fext = (char*) malloc(strlen(list[*list_sel].ext) + 1);
1319-
strcpy(fext, list[*list_sel].ext);
1319+
const char* ext2 = list[*list_sel].ext == NULL ? "" : list[*list_sel].ext;
1320+
fext = (char*) malloc(strlen(ext2) + 1);
1321+
strcpy(fext, ext2);
13201322
file_selector[FS_TYPES].d1 = *list_sel;
13211323

13221324
/* Set default attributes. */

0 commit comments

Comments
 (0)