Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
49ded3ec
Commit
49ded3ec
authored
Mar 19, 1999
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added check for negative offset for PyBuffer_FromObject and check for
negative size for PyBuffer_FromMemory. Greg Stein.
parent
7d5f5dd6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
1 deletion
+13
-1
Objects/bufferobject.c
Objects/bufferobject.c
+13
-1
No files found.
Objects/bufferobject.c
View file @
49ded3ec
...
...
@@ -55,6 +55,12 @@ _PyBuffer_FromMemory(base, ptr, size, readonly)
{
PyBufferObject
*
b
;
if
(
size
<
0
)
{
PyErr_SetString
(
PyExc_ValueError
,
"size must be zero or positive"
);
return
NULL
;
}
b
=
PyObject_NEW
(
PyBufferObject
,
&
PyBuffer_Type
);
if
(
b
==
NULL
)
return
NULL
;
...
...
@@ -83,6 +89,12 @@ _PyBuffer_FromObject(base, offset, size, proc, readonly)
void
*
p
;
int
count
;
if
(
offset
<
0
)
{
PyErr_SetString
(
PyExc_ValueError
,
"offset must be zero or positive"
);
return
NULL
;
}
if
(
(
*
pb
->
bf_getsegcount
)(
base
,
NULL
)
!=
1
)
{
PyErr_SetString
(
PyExc_TypeError
,
"single-segment buffer object expected"
);
...
...
@@ -92,7 +104,7 @@ _PyBuffer_FromObject(base, offset, size, proc, readonly)
return
NULL
;
/* apply constraints to the start/end */
if
(
size
==
Py_END_OF_BUFFER
)
if
(
size
==
Py_END_OF_BUFFER
||
size
<
0
)
size
=
count
;
if
(
offset
>
count
)
offset
=
count
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment