Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- libs/vkd3d-shader/vkd3d_shader_main.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/libs/vkd3d-shader/vkd3d_shader_main.c b/libs/vkd3d-shader/vkd3d_shader_main.c index 78312a14..9a4560a3 100644 --- a/libs/vkd3d-shader/vkd3d_shader_main.c +++ b/libs/vkd3d-shader/vkd3d_shader_main.c @@ -41,10 +41,12 @@ static void vkd3d_string_buffer_clear(struct vkd3d_string_buffer *buffer)
static bool vkd3d_string_buffer_resize(struct vkd3d_string_buffer *buffer, int rc) { - unsigned int new_buffer_size = buffer->buffer_size * 2; + unsigned int new_buffer_size = max(buffer->buffer_size * 2, 32); char *new_buffer;
- new_buffer_size = max(new_buffer_size, 32); + if (rc < buffer->buffer_size - buffer->content_size) + return true; + while (rc > 0 && (unsigned int)rc >= new_buffer_size - buffer->content_size) new_buffer_size *= 2; if (!(new_buffer = vkd3d_realloc(buffer->buffer, new_buffer_size)))