diff options
author | Frank Stein <dr.frank.stain@gmail.com> | 2015-07-14 00:10:11 +0300 |
---|---|---|
committer | Frank Stein <dr.frank.stain@gmail.com> | 2015-07-14 00:10:11 +0300 |
commit | a1d801c37558ffee1c1baffe5c5b2ecf01eb24b4 (patch) | |
tree | a332a43f5dc64be69f5654abcd16e20712acf3fa /python | |
parent | 4798456df63650d9d4d4f344e0efd01c30fddb23 (diff) | |
download | flatbuffers-a1d801c37558ffee1c1baffe5c5b2ecf01eb24b4.tar.gz flatbuffers-a1d801c37558ffee1c1baffe5c5b2ecf01eb24b4.tar.bz2 flatbuffers-a1d801c37558ffee1c1baffe5c5b2ecf01eb24b4.zip |
2Gb buffer size checks fixed for Python Builder
Diffstat (limited to 'python')
-rw-r--r-- | python/flatbuffers/builder.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/python/flatbuffers/builder.py b/python/flatbuffers/builder.py index 068c413f..4c78d7a6 100644 --- a/python/flatbuffers/builder.py +++ b/python/flatbuffers/builder.py @@ -93,7 +93,7 @@ class Builder(object): The internal buffer is grown as needed. """ - if not (0 <= initialSize < (2**UOffsetTFlags.bytewidth - 1)): + if not (0 <= initialSize <= self.MaxBufferSize()): msg = "flatbuffers: Cannot create Builder larger than 2 gigabytes." raise BuilderSizeError(msg) @@ -104,6 +104,12 @@ class Builder(object): self.objectEnd = None self.vtables = [] + def MaxBufferSize(self): + """ + Maximum buffer size is 2Gb. + """ + return 2**31 + def Output(self): """ Output returns the portion of the buffer that has been used for @@ -238,7 +244,7 @@ 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) <= 2**20: + if not len(self.Bytes) <= self.MaxBufferSize(): msg = "flatbuffers: cannot grow buffer beyond 2 gigabytes" raise BuilderSizeError(msg) |