Commit Graph

2121 Commits

Author SHA1 Message Date
Andrew M. Kuchling
154a884e6b [Backport r51221 | neal.norwitz -- the original commit message is wrong;
this code is only used if WITHOUT_COMPLEX is *not* defined, which is the
 common case for Python builds.]

This code is actually not used unless WITHOUT_COMPLEX is defined.
However, there was no error checking that PyFloat_FromDouble returned
a valid pointer.  I believe this change is correct as it seemed
to follow other code in the area.

Klocwork # 292.
2006-10-05 19:08:30 +00:00
Andrew M. Kuchling
720ea07788 [Backport r51220 | neal.norwitz]
It's highly unlikely, though possible for PyEval_Get*() to return NULLs.
So be safe and do an XINCREF.

Klocwork # 221-222.
2006-10-05 19:01:50 +00:00
Andrew M. Kuchling
e67841f113 [Backport r50685 | neal.norwitz]
Reported by Klocwork #151.

v2 can be NULL if exception2 is NULL.  I don't think that condition can happen,
but I'm not sure it can't either.  Now the code will protect against either
being NULL.
2006-10-05 18:57:54 +00:00
Andrew M. Kuchling
8a28c16430 [Backport r50743 | neal.norwitz]
Handle allocation failures gracefully.  Found with failmalloc.
Many (all?) of these could be backported.
2006-10-05 18:08:58 +00:00
Andrew M. Kuchling
fb369242bd [Backport r51247 | neal.norwitz]
cpathname could be NULL if it was longer than MAXPATHLEN.  Don't try
to write the .pyc to NULL.

Check results of PyList_GetItem() and PyModule_GetDict() are not NULL.

Klocwork 282, 283, 285
2006-10-05 17:19:30 +00:00
Andrew M. Kuchling
3b93688db6 [Backport r51245 | neal.norwitz]
Move/copy assert for tstate != NULL before first use.
Verify that PyEval_Get{Globals,Locals} returned valid pointers.

Klocwork 231-232
2006-10-04 13:17:42 +00:00
Armin Rigo
b2d0f34240 A review of overflow-detecting code in the 2.4 branch.
* unified the way intobject, longobject and mystrtoul handle
  values around -sys.maxint-1.

* in general, trying to entierely avoid overflows in any computation
  involving signed ints or longs is extremely involved.  Fixed a few
  simple cases where a compiler might be too clever (but that's all
  guesswork).

* more overflow checks against bad data in marshal.c.
2006-10-04 10:13:32 +00:00
Andrew M. Kuchling
a2040255ca [Partial backport of r50777 | neal.norwitz]
Handle more mem alloc issues found with failmalloc

[The other half of this patch affected Python/symtable.c, and wasn't
 relevant for the 2.4 branch. --amk]
2006-10-03 19:18:33 +00:00
Andrew M. Kuchling
58e5c1149a [Backport r51443 | neal.norwitz]
Handle a few more error conditions.

Klocwork 301 and 302.  Will backport.
2006-10-03 19:11:32 +00:00
Andrew M. Kuchling
fec7674420 [Backport r51231 | neal.norwitz]
PyModule_GetDict() can fail, produce fatal errors if this happens on startup.

Klocwork #298-299.
2006-10-03 19:08:48 +00:00
Andrew M. Kuchling
1c0d8f0fec [Backport r50678 | neal.norwitz]
Fix memory leak under some conditions.

Reported by Klocwork, #98.
2006-10-03 18:32:25 +00:00
Andrew M. Kuchling
21e2af3562 [Backport rev. 41696 by neal.norwitz]
Fix an int/long mismatch identified here:
        http://www.tortall.net/mu/blog/2005/12/01

Pointed out from SF #1365916.

Backport candidate.
2006-09-29 17:52:32 +00:00
Andrew M. Kuchling
e7031223e3 [Backport of rev. 42093 by neal.norwitz]
Check return result from Py_InitModule*().  This API can fail.

Probably should be backported.
2006-09-27 19:17:32 +00:00
Georg Brandl
b302323c65 Backport fixes for #1523610 (crashes in PyArg_ParseTuple):
rev. 51158 and rev. 50843.
2006-08-09 07:15:29 +00:00
Georg Brandl
4eb9634368 Bug #1535165: fixed a segfault in input() and raw_input() when
sys.stdin is closed.
 (backport from rev. 51129)
2006-08-06 08:23:59 +00:00
Andrew MacIntyre
1fe0665fb6 Complete backport of rev 50787 that was started in rev 50788 2006-07-23 14:29:02 +00:00
Andrew MacIntyre
5596679a4a bugfix: PyThread_start_new_thread() returns the thread ID, not a flag;
backport of rev 50787.
2006-07-23 13:01:03 +00:00
Georg Brandl
8532999ccf Argh. "integer" is a very confusing word ;)
Actually, checking for INT_MAX and INT_MIN is correct since
the format code explicitly handles a C "int".
 (backport from rev. 46746)
2006-06-08 13:31:14 +00:00
Georg Brandl
78fbb2a032 Bug #1502750: Fix getargs "i" format to use LONG_MIN and LONG_MAX for bounds checking.
(backport from rev. 46741)
2006-06-08 12:45:05 +00:00
Brett Cannon
89d862360c Fix possible buffer overflow on Windows when reading code page.
Backport of fix for bug #1501223.
2006-06-05 23:56:36 +00:00
Thomas Wouters
eba52802cd Backport trunk's r45715:
Define MAXPATHLEN to be at least PATH_MAX, if that's defined. Python uses
MAXPATHLEN-sized buffers for various output-buffers (like to realpath()),
and that's correct on BSD platforms, but not Linux (which uses PATH_MAX, and
does not define MAXPATHLEN.) Cursory googling suggests Linux is following a
newer standard than BSD, but in cases like this, who knows. Using the
greater of PATH_MAX and 1024 as a fallback for MAXPATHLEN seems to be the
most portable solution.
2006-04-25 15:33:48 +00:00
Armin Rigo
337c143b4a Ignore the references to the dummy objects used as deleted keys
in dicts and sets when computing the total number of references.
2006-04-12 17:06:58 +00:00
Martin v. Löwis
adbd28f7b8 Backport of compile.c part of r41531 (neal.norwitz, 2005-11-24):
Fix a ref leak.
2006-03-27 21:47:54 +00:00
Anthony Baxter
022a55c0d9 update - still some old .cvsignore files lying around 2006-03-23 02:26:07 +00:00
Martin v. Löwis
73c8c2c3dd Change SystemError into SyntaxError, when a Unicode string
containing an encoding declaration is compile()d. Fixes
#1115379.
2006-03-22 13:55:50 +00:00