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
8cda5e60
Commit
8cda5e60
authored
Jul 26, 2013
by
Christian Heimes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Coverity: model PyLong_From*() functions
parent
ebf4204e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
5 deletions
+30
-5
Misc/coverity_model.c
Misc/coverity_model.c
+30
-5
No files found.
Misc/coverity_model.c
View file @
8cda5e60
...
...
@@ -19,8 +19,10 @@
/* dummy definitions, in most cases struct fields aren't required. */
#define NULL (void *)0
#define assert(op)
/* empty */
typedef
int
sdigit
;
typedef
long
Py_ssize_t
;
typedef
long
long
PY_LONG_LONG
;
typedef
unsigned
short
wchar_t
;
typedef
struct
{}
PyObject
;
typedef
struct
{}
grammar
;
...
...
@@ -37,17 +39,40 @@ void Py_FatalError(const char *msg) {
/* Objects/longobject.c
* NEGATIVE_RETURNS false positive */
static
PyObject
small_ints
[
257
+
5
];
static
PyObject
*
get_small_int
(
sdigit
ival
)
{
/* Never returns NULL */
PyObject
*
p
;
if
(((
ival
+
5
)
>=
0
)
&&
((
ival
+
5
)
<
257
+
5
))
{
return
&
small_ints
[
ival
+
5
];
}
assert
(
p
!=
NULL
);
return
p
;
}
PyObject
*
PyLong_FromLong
(
long
ival
)
{
PyObject
*
p
;
int
maybe
;
if
((
ival
>=
-
5
)
&&
(
ival
<
257
+
5
))
{
p
=
get_small_int
(
ival
);
assert
(
p
!=
NULL
);
return
p
;
}
if
(
maybe
)
return
p
;
else
return
NULL
;
}
PyObject
*
PyLong_FromLongLong
(
PY_LONG_LONG
ival
)
{
return
PyLong_FromLong
((
long
)
ival
);
}
PyObject
*
PyLong_FromSsize_t
(
Py_ssize_t
ival
)
{
return
PyLong_FromLong
((
long
)
ival
);
}
/* tainted sinks
*
* Coverity considers argv, environ, read() data etc as tained.
...
...
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