Commit Graph

2311 Commits

Author SHA1 Message Date
Tim Peters
0af9b87953 Backport rev 51262 from trunk -- squashes a compiler warning on Windows
about truly wrong code.

Checkin comment from 51262:

Can't return NULL from a void function.  If there is a memory error,
about the best we can do is call PyErr_WriteUnraisable and go on.
We won't be able to do the call below either, so verify delstr is valid.
2006-10-09 23:37:58 +00:00
Tim Peters
2b37ea4087 Backport of the pieces of trunk rev 46589 relevant to
fixing an unlikely crash bug in dict resizing, SF
bug 1456209.

The rest of rev 46589 changes whether Python suppresses
exceptions during some dict-related comparisons.  While I
think that's a good idea, it does change visible behavior at
times, and there was already some complaining about that on
the trunk.  Not a good idea for backporting.  The part of
46589 checked in here can at worst stop segfaults, and I doubt
anyone will gripe about that ;-)
2006-10-09 20:24:45 +00:00
Andrew M. Kuchling
2fafa251db [Partial backport of r45947 | neal.norwitz]
Fix problems found by Coverity.

longobject.c: also fix an ssize_t problem
  <a> could have been NULL, so hoist the size calc to not use <a>.

[The ssize_t change isn't needed for 2.4.  The other changes in this revision
 are to modules not present in 2.4. --amk]
2006-10-09 18:42:49 +00:00
Andrew M. Kuchling
e0235ae1a9 [Backport r42951 | guido.van.rossum]
Fix three nits found by Coverity, adding null checks and comments.

[This commit only makes two changes.  One change in the original patch
 is just adding a comment, and another adds a 'base != NULL' check to
 silence Coverity, but a comment adds that that base is never going to
 be NULL.  I didn't backport that change. --amk]
2006-10-09 18:19:01 +00:00
Andrew M. Kuchling
78754c13ce [Backport r43695 | neal.norwitz]
Remove dead code (reported by HP compiler).

Can probably be backported if anyone cares.
2006-10-06 19:26:14 +00:00
Andrew M. Kuchling
3e3566937e [Backport r50679 | neal.norwitz. This is the last Klocwork bug to be
backported.]

Use sizeof(buffer) instead of duplicating the constants to ensure they won't
be wrong.

The real change is to pass (bufsz - 1) to PyOS_ascii_formatd and 1
to strncat.  strncat copies n+1 bytes from src (not dest).

Reported by Klocwork #58.
2006-10-05 19:42:49 +00:00
Andrew M. Kuchling
32f378b0d9 [Backport r50681 | neal.norwitz]
PyFunction_SetDefaults() is documented as taking None or a tuple.
A NULL would crash the PyTuple_Check().  Now make NULL return a SystemError.

Reported by Klocwork #73.
2006-10-05 19:38:17 +00:00
Andrew M. Kuchling
6d0bc3e9f4 [Backport r51246 | neal.norwitz]
Handle a whole lot of failures from PyString_FromInternedString().

Should fix most of Klocwork 234-272.

[Backport r51400 | neal.norwitz]

Move initialization of interned strings to before allocating the
object so we don't leak op.  (Fixes an earlier patch to this code)

Klockwork #350
2006-10-05 19:25:26 +00:00
Andrew M. Kuchling
978809518d [Partial backport of r51218 | neal.norwitz -- the changes to ast.c, symtable.c,
and _elementtree.c weren't applicable]

Klocwork made another run and found a bunch more problems.
This is the first batch of fixes that should be easy to verify based on context.
This fixes problem numbers: 220 (ast), 323-324 (symtable),
321-322 (structseq), 215 (array), 210 (hotshot), 182 (codecs), 209 (etree).
2006-10-05 18:37:08 +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
1af9f68b4a [Backport r51248 | neal.norwitz]
Fix segfault when doing string formatting on subclasses of long if
__oct__, __hex__ don't return a string.

Klocwork 308
2006-10-05 17:18:13 +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
Martin v. Löwis
98041d7bf0 Fix integer negation and absolute value to not rely
on undefined behaviour of the C compiler anymore.
2006-10-04 05:48:05 +00:00
Andrew M. Kuchling
59e0e1e395 [Backport r51230 | neal.norwitz]
Check return of PyMem_MALLOC (garbage) is non-NULL.
Check seq in both portions of if/else.

Klocwork #289-290.
2006-10-03 19:07:06 +00:00
Andrew M. Kuchling
b1d7043290 [Backport r50779 | neal.norwitz]
Move the initialization of size_a down below the check for a being NULL.

Reported by Klocwork #106.

[Slight change required: in 2.5 Py_ssize_t is used, but 2.4 uses int.]
2006-10-03 18:52:07 +00:00
Andrew M. Kuchling
5cf2fb9904 [Backport r50683 | neal.norwitz]
Stop INCREFing name, then checking if it's NULL.  name (f_name) should never
be NULL so assert it.  Fix one place where we could have passed NULL.

Reported by Klocwork #66.
2006-10-03 18:43:28 +00:00
Andrew M. Kuchling
91697928ca [Backport r50680 | neal.norwitz]
Handle a NULL name properly.
2006-10-03 18:40:23 +00:00
Andrew M. Kuchling
c6994f2502 [Backport rev. 42545 by georg.brandl]
Make staticmethod and classmethod complain about keyword args.
2006-10-03 18:25:19 +00:00
Andrew M. Kuchling
26acb2cc88 [Backport rev. 51669 by brett.cannon]
Make sure memory is properly cleaned up in file_init.

Backport candidate.
2006-10-03 13:04:29 +00:00
Andrew M. Kuchling
ceb4914f42 [Backport rev. 47171 by neal.norwitz]
Another problem reported by Coverity.  Backport candidate.
2006-10-03 12:58:52 +00:00
Georg Brandl
adf8a1d0cb Patch #1567691: super() and new.instancemethod() now don't accept
keyword arguments any more (previously they accepted them, but didn't
use them).
 (backport from rev. 52058)
2006-09-30 08:43:35 +00:00
Andrew M. Kuchling
942f75df60 [Backport rev. 46878 by neal.norwitz]
Don't leak the list object if there's an error allocating the item
storage.  Backport candidate.
2006-09-29 18:22:07 +00:00
Andrew M. Kuchling
ab68637b52 [Backport rev. 39743 by lemburg]
Bug fix for [ 1331062 ] utf 7 codec broken.

Backport candidate.
2006-09-29 17:57:58 +00:00
Tim Peters
e63dab55ec Merge rev 51711 from the 2.5 branch.
i_divmod():  As discussed on Python-Dev, changed the overflow
checking to live happily with recent gcc optimizations that
assume signed integer arithmetic never overflows.
2006-09-05 02:00:47 +00:00
Georg Brandl
79ba8e53aa Backport rev 51448:
- Patch #1541585: fix buffer overrun when performing repr() on
  a unicode string in a build with wide unicode (UCS-4) support.
2006-08-22 08:25:33 +00:00