From 33e4ab65e9b2c3d6986523f803d83c695477bb38 Mon Sep 17 00:00:00 2001
From: Frank Stein <dr.frank.stain@gmail.com>
Date: Fri, 14 Aug 2015 00:50:39 +0300
Subject: [PATCH] Incorrect buffer size check fixed.

---
 python/flatbuffers/builder.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/python/flatbuffers/builder.py b/python/flatbuffers/builder.py
index d59d8c4c..3e7f3ceb 100644
--- a/python/flatbuffers/builder.py
+++ b/python/flatbuffers/builder.py
@@ -245,11 +245,11 @@ class Builder(object):
     def growByteBuffer(self):
         """Doubles the size of the byteslice, and copies the old data towards
            the end of the new buffer (since we build the buffer backwards)."""
-        if not len(self.Bytes) <= Builder.MAX_BUFFER_SIZE:
+        if len(self.Bytes) == Builder.MAX_BUFFER_SIZE:
             msg = "flatbuffers: cannot grow buffer beyond 2 gigabytes"
             raise BuilderSizeError(msg)
 
-        newSize = min( len(self.Bytes) * 2, Builder.MAX_BUFFER_SIZE )
+        newSize = min(len(self.Bytes) * 2, Builder.MAX_BUFFER_SIZE)
         if newSize == 0:
             newSize = 1
         bytes2 = bytearray(newSize)
-- 
GitLab