#define wmemmove(a,b,i) (wchar_t *)memmove((a), (b), (i) * sizeof(wchar_t))
#endif
+#undef max
+#define max(a, b) ((a)>(b)?(a):(b))
+
struct archive_string_conv {
struct archive_string_conv *next;
char *from_charset;
as->s[as->length] = '\0';
/* Re-allocate buffer for MBS. */
if (archive_string_ensure(as,
- as->length + len * 2 + 1) == NULL)
+ as->length + max(len * 2,
+ (size_t)MB_CUR_MAX) + 1) == NULL)
return (-1);
p = as->s + as->length;
end = as->s + as->buffer_length - MB_CUR_MAX -1;
as->length = p - as->s;
/* Re-allocate buffer for MBS. */
if (archive_string_ensure(as,
- as->length + len * 2 + 1) == NULL)
+ as->length + max(len * 2,
+ (size_t)MB_CUR_MAX) + 1) == NULL)
return (-1);
p = as->s + as->length;
end = as->s + as->buffer_length - MB_CUR_MAX -1;