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
f13c46cc
Commit
f13c46cc
authored
Aug 17, 2014
by
Victor Stinner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #22218: Fix "comparison between signed and unsigned integers" warnings in
Modules/_pickle.c.
parent
1a62a680
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
10 deletions
+11
-10
Modules/_pickle.c
Modules/_pickle.c
+11
-10
No files found.
Modules/_pickle.c
View file @
f13c46cc
...
@@ -420,22 +420,22 @@ static int
...
@@ -420,22 +420,22 @@ static int
Pdata_grow
(
Pdata
*
self
)
Pdata_grow
(
Pdata
*
self
)
{
{
PyObject
**
data
=
self
->
data
;
PyObject
**
data
=
self
->
data
;
Py_ssize_t
allocated
=
self
->
allocated
;
size_t
allocated
=
(
size_t
)
self
->
allocated
;
Py_s
size_t
new_allocated
;
size_t
new_allocated
;
new_allocated
=
(
allocated
>>
3
)
+
6
;
new_allocated
=
(
allocated
>>
3
)
+
6
;
/* check for integer overflow */
/* check for integer overflow */
if
(
new_allocated
>
PY_SSIZE_T_MAX
-
allocated
)
if
(
new_allocated
>
(
size_t
)
PY_SSIZE_T_MAX
-
allocated
)
goto
nomemory
;
goto
nomemory
;
new_allocated
+=
allocated
;
new_allocated
+=
allocated
;
if
(
new_allocated
>
(
PY_SSIZE_T_MAX
/
sizeof
(
PyObject
*
)))
if
(
new_allocated
>
(
(
size_t
)
PY_SSIZE_T_MAX
/
sizeof
(
PyObject
*
)))
goto
nomemory
;
goto
nomemory
;
data
=
PyMem_REALLOC
(
data
,
new_allocated
*
sizeof
(
PyObject
*
));
data
=
PyMem_REALLOC
(
data
,
new_allocated
*
sizeof
(
PyObject
*
));
if
(
data
==
NULL
)
if
(
data
==
NULL
)
goto
nomemory
;
goto
nomemory
;
self
->
data
=
data
;
self
->
data
=
data
;
self
->
allocated
=
new_allocated
;
self
->
allocated
=
(
Py_ssize_t
)
new_allocated
;
return
0
;
return
0
;
nomemory:
nomemory:
...
@@ -850,7 +850,7 @@ _Pickler_ClearBuffer(PicklerObject *self)
...
@@ -850,7 +850,7 @@ _Pickler_ClearBuffer(PicklerObject *self)
static
void
static
void
_write_size64
(
char
*
out
,
size_t
value
)
_write_size64
(
char
*
out
,
size_t
value
)
{
{
in
t
i
;
size_
t
i
;
assert
(
sizeof
(
size_t
)
<=
8
);
assert
(
sizeof
(
size_t
)
<=
8
);
...
@@ -2118,12 +2118,13 @@ write_utf8(PicklerObject *self, char *data, Py_ssize_t size)
...
@@ -2118,12 +2118,13 @@ write_utf8(PicklerObject *self, char *data, Py_ssize_t size)
char
header
[
9
];
char
header
[
9
];
Py_ssize_t
len
;
Py_ssize_t
len
;
assert
(
size
>=
0
);
if
(
size
<=
0xff
&&
self
->
proto
>=
4
)
{
if
(
size
<=
0xff
&&
self
->
proto
>=
4
)
{
header
[
0
]
=
SHORT_BINUNICODE
;
header
[
0
]
=
SHORT_BINUNICODE
;
header
[
1
]
=
(
unsigned
char
)(
size
&
0xff
);
header
[
1
]
=
(
unsigned
char
)(
size
&
0xff
);
len
=
2
;
len
=
2
;
}
}
else
if
(
size
<=
0xffffffffUL
)
{
else
if
(
(
size_t
)
size
<=
0xffffffffUL
)
{
header
[
0
]
=
BINUNICODE
;
header
[
0
]
=
BINUNICODE
;
header
[
1
]
=
(
unsigned
char
)(
size
&
0xff
);
header
[
1
]
=
(
unsigned
char
)(
size
&
0xff
);
header
[
2
]
=
(
unsigned
char
)((
size
>>
8
)
&
0xff
);
header
[
2
]
=
(
unsigned
char
)((
size
>>
8
)
&
0xff
);
...
@@ -4505,10 +4506,10 @@ static Py_ssize_t
...
@@ -4505,10 +4506,10 @@ static Py_ssize_t
calc_binsize
(
char
*
bytes
,
int
nbytes
)
calc_binsize
(
char
*
bytes
,
int
nbytes
)
{
{
unsigned
char
*
s
=
(
unsigned
char
*
)
bytes
;
unsigned
char
*
s
=
(
unsigned
char
*
)
bytes
;
in
t
i
;
Py_ssize_
t
i
;
size_t
x
=
0
;
size_t
x
=
0
;
for
(
i
=
0
;
i
<
nbytes
&&
i
<
sizeof
(
size_t
);
i
++
)
{
for
(
i
=
0
;
i
<
nbytes
&&
(
size_t
)
i
<
sizeof
(
size_t
);
i
++
)
{
x
|=
(
size_t
)
s
[
i
]
<<
(
8
*
i
);
x
|=
(
size_t
)
s
[
i
]
<<
(
8
*
i
);
}
}
...
@@ -4527,7 +4528,7 @@ static long
...
@@ -4527,7 +4528,7 @@ static long
calc_binint
(
char
*
bytes
,
int
nbytes
)
calc_binint
(
char
*
bytes
,
int
nbytes
)
{
{
unsigned
char
*
s
=
(
unsigned
char
*
)
bytes
;
unsigned
char
*
s
=
(
unsigned
char
*
)
bytes
;
in
t
i
;
Py_ssize_
t
i
;
long
x
=
0
;
long
x
=
0
;
for
(
i
=
0
;
i
<
nbytes
;
i
++
)
{
for
(
i
=
0
;
i
<
nbytes
;
i
++
)
{
...
...
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