Skip to content

Commit 1b8a607

Browse files
dkondorammen99
authored andcommitted
Fix crash with parentheses in filenames (#204)
* Fix crash with parentheses in filenames Also free the elements of the wordexp_t struct used. * Handle the empty string case
1 parent c19e899 commit 1b8a607

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

src/background/background.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,15 +120,21 @@ bool WayfireBackground::load_images_from_dir(std::string path)
120120
wordexp_t exp;
121121

122122
/* Expand path */
123-
wordexp(path.c_str(), &exp, 0);
124-
if (!exp.we_wordv)
123+
if (wordexp(path.c_str(), &exp, 0))
125124
{
126125
return false;
127126
}
128127

128+
if (!exp.we_wordc)
129+
{
130+
wordfree(&exp);
131+
return false;
132+
}
133+
129134
auto dir = opendir(exp.we_wordv[0]);
130135
if (!dir)
131136
{
137+
wordfree(&exp);
132138
return false;
133139
}
134140

@@ -158,6 +164,8 @@ bool WayfireBackground::load_images_from_dir(std::string path)
158164
}
159165
}
160166

167+
wordfree(&exp);
168+
161169
if (background_randomize && images.size())
162170
{
163171
std::random_device random_device;

0 commit comments

Comments
 (0)