Skip to content

Commit db1863d

Browse files
Fix undefined behavior when lowercasing string
Mac OS builds were complaining that incrementing a pointer while assigning it was undefined behavior.
1 parent aac1fe3 commit db1863d

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

plugin.c

+8-2
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,10 @@ static void configure_set(struct PluginSet *set)
142142
set->data = data;
143143
data->set = set;
144144
c = data->name_lc = strdup(set->prefix);
145-
while ((*c++ = tolower(*c)));
145+
146+
for(int i = 0; c[i]; i++){
147+
c[i] = tolower(c[i]);
148+
}
146149

147150
if (set->initial_paths) {
148151
paths = strdup(set->initial_paths);
@@ -215,7 +218,10 @@ static struct PluginList *find_plugin(struct PluginSet *set, const char *name,
215218
if (len >= sizeof(_name))
216219
c = name_lc = malloc(len + 1);
217220
strcpy(name_lc, name);
218-
while ((*c++ = tolower(*c)));
221+
222+
for(int i = 0; c[i]; i++){
223+
c[i] = tolower(c[i]);
224+
}
219225

220226
for (dirs = set->data->dirs; dirs && dirs->dir; dirs = dirs->next) {
221227
snprintf(path, sizeof(path), "%s/%s-%s" PL_PLUGIN_SUFFIX, dirs->dir->path,

0 commit comments

Comments
 (0)