diff --git a/src/xpdev/str_list.c b/src/xpdev/str_list.c index 57e380a64227051a4681d9a96ba2fcf0a3f7b2b7..4f29c2328bd2d54dff8c1528b33cedb9857e0307 100644 --- a/src/xpdev/str_list.c +++ b/src/xpdev/str_list.c @@ -202,15 +202,14 @@ size_t DLLCALL strListModifyEach(const str_list_t list, char*(modify(size_t, cha { size_t i; for(i = 0; list[i] != NULL; i++) { - char* p; char* str = modify(i, list[i], cbdata); - if(str == NULL || str == list[i]) // Same old pointer (or NULL), no realloc() needed + if(str == NULL || str == list[i]) // Same old pointer (or NULL), no modification continue; - p = realloc(list[i], strlen(str) + 1); - if(p == NULL) + str = strdup(str); + if(str == NULL) break; - list[i] = p; - strcpy(p, str); + free(list[i]); + list[i] = str; } return i; }