Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
F
fuchsia.googlesource.com-third_party-flatbuffers
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
fuchsia-mirror
fuchsia.googlesource.com-third_party-flatbuffers
Commits
a1d801c3
Commit
a1d801c3
authored
9 years ago
by
Frank Stein
Browse files
Options
Downloads
Patches
Plain Diff
2Gb buffer size checks fixed for Python Builder
parent
4798456d
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
python/flatbuffers/builder.py
+8
-2
8 additions, 2 deletions
python/flatbuffers/builder.py
with
8 additions
and
2 deletions
python/flatbuffers/builder.py
+
8
−
2
View file @
a1d801c3
...
@@ -93,7 +93,7 @@ class Builder(object):
...
@@ -93,7 +93,7 @@ class Builder(object):
The internal buffer is grown as needed.
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.
"
msg
=
"
flatbuffers: Cannot create Builder larger than 2 gigabytes.
"
raise
BuilderSizeError
(
msg
)
raise
BuilderSizeError
(
msg
)
...
@@ -104,6 +104,12 @@ class Builder(object):
...
@@ -104,6 +104,12 @@ class Builder(object):
self
.
objectEnd
=
None
self
.
objectEnd
=
None
self
.
vtables
=
[]
self
.
vtables
=
[]
def
MaxBufferSize
(
self
):
"""
Maximum buffer size is 2Gb.
"""
return
2
**
31
def
Output
(
self
):
def
Output
(
self
):
"""
"""
Output returns the portion of the buffer that has been used for
Output returns the portion of the buffer that has been used for
...
@@ -238,7 +244,7 @@ class Builder(object):
...
@@ -238,7 +244,7 @@ class Builder(object):
def
growByteBuffer
(
self
):
def
growByteBuffer
(
self
):
"""
Doubles the size of the byteslice, and copies the old data towards
"""
Doubles the size of the byteslice, and copies the old data towards
the end of the new buffer (since we build the buffer backwards).
"""
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
"
msg
=
"
flatbuffers: cannot grow buffer beyond 2 gigabytes
"
raise
BuilderSizeError
(
msg
)
raise
BuilderSizeError
(
msg
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment