[gtk/wip/chergert/fix-3770] ngl: ensure vertices buffer allocates enough vertices




commit 56daad9c3527a90cca2aee2854e1c26d18d74341
Author: Christian Hergert <chergert redhat com>
Date:   Thu Mar 18 10:43:24 2021 -0700

    ngl: ensure vertices buffer allocates enough vertices
    
    It's not guaranteed that a single power of two growth will be enough.
    
    Fixes #3770

 gsk/ngl/gsknglbufferprivate.h | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
---
diff --git a/gsk/ngl/gsknglbufferprivate.h b/gsk/ngl/gsknglbufferprivate.h
index fc67bc9e0b..cbd21c83da 100644
--- a/gsk/ngl/gsknglbufferprivate.h
+++ b/gsk/ngl/gsknglbufferprivate.h
@@ -32,7 +32,7 @@ typedef struct _GskNglBuffer
   gsize   buffer_len;
   guint   count;
   GLenum  target;
-  guint   element_size;
+  gsize   element_size;
 } GskNglBuffer;
 
 void   gsk_ngl_buffer_init    (GskNglBuffer *self,
@@ -50,7 +50,8 @@ gsk_ngl_buffer_advance (GskNglBuffer *buffer,
 
   if G_UNLIKELY (buffer->buffer_pos + to_alloc > buffer->buffer_len)
     {
-      buffer->buffer_len *= 2;
+      while (buffer->buffer_pos + to_alloc > buffer->buffer_len)
+        buffer->buffer_len *= 2;
       buffer->buffer = g_realloc (buffer->buffer, buffer->buffer_len);
     }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]