Commit Graph

94 Commits

Author SHA1 Message Date
Gregory P. Smith 0812de63c2 fix issue2858: potential memory corruption when any of the bsddb.db.*
constructors raised an exception.  backportes from trunk c63403.
2008-05-17 06:46:39 +00:00
Gregory P. Smith 946de92f9b backport r60544 from trunk:
Merge this fix from the pybsddb tree:
r293 | jcea | 2008-01-31 01:08:19 -0800 (Thu, 31 Jan 2008) | 4 lines

Solved memory leak when using cursors with
databases without environment.
2008-02-03 07:26:23 +00:00
Gregory P. Smith 2e49f781cb * fix failing test_recno.py - backport from trunk.
* bump _bsddb patch version number.
2007-11-07 07:25:20 +00:00
Gregory P. Smith 2c3e0d94b2 Backport r58757, r58758, r58759.
Undoes incorrect dbtables fix and errant strdup introduced as
described below:

r58757 | gregory.p.smith | 2007-11-01 14:08:14 -0700 (Thu, 01 Nov 2007) | 4 lines

Fix bug introduced in revision 58385.  Database keys could no longer
have NULL bytes in them.  Replace the errant strdup with a
malloc+memcpy.  Adds a unit test for the correct behavior.

r58758 | gregory.p.smith | 2007-11-01 14:15:36 -0700 (Thu, 01 Nov 2007) | 3 lines

Undo revision 58533 58534 fixes.  Those were a workaround for
a problem introduced by 58385.

r58759 | gregory.p.smith | 2007-11-01 14:17:47 -0700 (Thu, 01 Nov 2007) | 2 lines

false "fix" undone as correct problem was found and fixed.
2007-11-01 21:22:40 +00:00
Gregory P. Smith 7d9c00ec4f Backport 58385 from trunk: fix a double free bug in the _bsddb module
on DBCursor.get (and a friends) when passing in a string key.
2007-10-09 07:25:24 +00:00
Gregory P. Smith 381e1a46cd Backport rev 58343: fix DBSequence.get_key() to not crash/fail/etc. 2007-10-06 16:05:18 +00:00
Neal Norwitz df73802131 Backout the original 'fix' to 1721309 which had no effect.
Different versions of Berkeley DB handle this differently.
The comments and bug report should have the details.  Memory is allocated
in 4.4 (and presumably earlier), but not in 4.5.  Thus
4.5 has the free error, but not earlier versions.

Mostly update comments, plus make the free conditional.
2007-05-20 02:14:48 +00:00
Neal Norwitz 73bf1018d6 Backport rev 55452:
Whoops, need to pay attention to those test failures.
Move the clear to *before* the first use, not after.
2007-05-19 04:37:31 +00:00
Neal Norwitz f86ae691d3 Backport rev 55450:
SF bug #1721309: Clear data so random memory does not get freed.
2007-05-19 03:53:33 +00:00
Gregory P. Smith 1a050f5f52 support linking the _bsddb extension module against BerkeleyDB 4.5
[backport of r53252]
2007-01-05 02:09:06 +00:00
Neal Norwitz 5890a6a8a6 Backport of 52811:
Bug #1599782: Fix segfault on bsddb.db.DB().type().

The problem is that _DB_get_type() can't be called without the GIL
because it calls a bunch of PyErr_* APIs when an error occurs.
There were no other cases in this file that it was called without the GIL.
Removing the BEGIN/END THREAD around _DB_get_type() made everything work.
2006-11-21 05:29:34 +00:00
Gregory P. Smith 6fed7937c6 fix: DB.stat flags and txn keyword arguments were backwards. 2006-09-30 06:05:07 +00:00
Neal Norwitz 5aa96895d8 Handle malloc and fopen failures more gracefully.
Klocwork 180-181
2006-08-13 18:11:43 +00:00
Gregory P. Smith 641cddf0fa - pybsddb Bug #1527939: bsddb module DBEnv dbremove and dbrename
methods now allow their database parameter to be None as the
  sleepycat API allows.

Also adds an appropriate test case for DBEnv.dbrename and dbremove.
2006-07-28 01:35:25 +00:00
Neal Norwitz dce937f32c Ensure we don't write beyond errText. I think I got this right, but
it definitely could use some review to ensure I'm not off by one
and there's no possible overflow/wrap-around of bytes_left.
Reported by Klocwork #1.

Fix a problem if there is a failure allocating self->db.
Found with failmalloc.
2006-07-23 08:01:43 +00:00
Neal Norwitz e75cad6125 Fix memory leak reported by valgrind while running test_subprocess 2006-06-17 22:38:15 +00:00
Martin v. Löwis 70ee3ccd1e Get rid of function pointer cast. 2006-06-12 04:26:31 +00:00
Neal Norwitz 09a29fae8f Cleanup Py_ssize_t a little (get rid of second #ifdef) 2006-06-12 02:05:55 +00:00
Neal Norwitz b4fcf8d787 Fix Coverity # 146. newDBSequenceObject would deref dbobj, so it can't be NULL.
We know it's not NULL from the ParseTuple and DbObject_Check will verify
it's not NULL.
2006-06-11 05:44:18 +00:00
Tim Peters bb21b2c50c BSequence_set_range(): Rev 46688 ("Fix a bunch of
parameter strings") changed this function's signature
seemingly by mistake, which is causing buildbots to fail
test_bsddb3.  Restored the pre-46688 signature.
2006-06-06 15:50:17 +00:00
Neal Norwitz dd2a6bf14f Fix a bunch of parameter strings 2006-06-06 07:23:01 +00:00
Gregory P. Smith 3c228b19f0 - bsddb: the __len__ method of a DB object has been fixed to return correct
results.  It could previously incorrectly return 0 in some cases.
  Fixes SF bug 1493322 (pybsddb bug 1184012).
2006-06-05 23:59:37 +00:00
Gregory P. Smith 372b583a6b * fix DBCursor.pget() bug with keyword argument names when no data= is
supplied [SF pybsddb bug #1477863]
2006-06-05 18:48:21 +00:00
Gregory P. Smith f0547d0d3e * add support for DBSequence objects [patch #1466734] 2006-06-05 17:38:04 +00:00
Gregory P. Smith db8a80735b * support DBEnv.lsn_reset() method on BerkeleyDB >= 4.4 [patch #1494902] 2006-06-05 01:56:15 +00:00
Gregory P. Smith 76a82e89ab * support DBEnv.log_stat() method on BerkeleyDB >= 4.0 [patch #1494885] 2006-06-05 01:39:52 +00:00
Gregory P. Smith bad474544c fix a bug in the previous commit. don't leak empty list on error return and
fix the additional rare (out of memory only) bug that it was supposed to fix
of not freeing log_list when the python allocator failed.
2006-06-05 00:33:35 +00:00
Gregory P. Smith 3dd20022ac bugfix: when log_archive was called with the DB_ARCH_REMOVE flag present
in BerkeleyDB >= 4.2 it tried to construct a list out of an uninitialized
char **log_list.

feature: export the DB_ARCH_REMOVE flag by name in the module on BerkeleyDB >= 4.2.
2006-06-05 00:31:01 +00:00
Georg Brandl 96a8c3954c Make use of METH_O and METH_NOARGS where possible.
Use Py_UnpackTuple instead of PyArg_ParseTuple where possible.
2006-05-29 21:04:52 +00:00
Gregory P. Smith 7f5b6f4b33 Fix bsddb.db.DBError derived exceptions so they can be unpickled.
Also adds some backwards compatibility when compiling _bsddb.c on earlier
python versions (needed for pybsddb).
2006-04-08 07:10:51 +00:00
Thomas Wouters b2820ae355 Fix another leak in bsddb, and avoid use of uninitialized value -- funny how
gcc 4.0.x wasn't complaining about *that* one ;)
2006-03-12 00:01:38 +00:00
Thomas Wouters b3153832c2 Clean up _bsddb.c: add a couple dozen missing Py_DECREF()'s, a handful of
missing PyObject_Del()'s, simplify some code by using Py_BuildValue()
instead of creating a tuple with items manually, stop clobbering builtin
exceptions in a few places, and guard against NULL-returning functions some
more.

This fixes 117 of the 780 (!?!#%@#$!!) reference leaks in test_bsddb3. I
ain't not done yet, although this review of 5kloc was just the easy part.
2006-03-08 01:47:19 +00:00
Georg Brandl ef1701f7d3 Add additional missing checks for return vals of PyTuple_New().
Normalize coding style.
2006-03-07 14:57:48 +00:00
Thomas Wouters 89ba38152d Fix gcc 4.0.x warning about use of uninitialized value. 2006-03-07 14:14:51 +00:00
Thomas Wouters 098f6943c0 Coverity found bug: test result of PyTuple_New() against NULL before use.
Will backport.
2006-03-07 14:13:17 +00:00
Thomas Wouters 9d63ccae90 Fix DBEnv's set_tx_timestamp wrapper to be slightly more correct on
non-32bit platforms. Will still only allow 32 bits in a timestamp on Win64,
but at least it won't crash, and it'll work right on platforms where longs
are big enough to contain time_t's.

(A better-working, although conceptually less-right fix would have been to
use Py_ssize_t here, but Martin and Tim won't let me.)
2006-03-01 01:01:55 +00:00
Tim Peters 85b1052efe Another bit of unconstification. 2006-02-28 18:33:35 +00:00
Martin v. Löwis 02cbf4ae4b More unconsting. 2006-02-27 17:20:04 +00:00
Martin v. Löwis 18e165558b Merge ssize_t branch. 2006-02-15 17:27:45 +00:00
Gregory P. Smith fd049a696d maintain support for older python versions in this module so that it
is ok for a standalone pybsddb source dist for use with <= 2.3.
2006-01-30 00:22:08 +00:00
Gregory P. Smith 8a47404799 Add wrapper for DBEnv.set_tx_timeout method to allow time based DB_RECOVER 2006-01-27 07:05:40 +00:00
Neal Norwitz 62a21121b4 Fix bug #1413192, fix seg fault in bsddb if a txn was deleted before the env.
Will backport.
2006-01-25 05:21:55 +00:00
Gregory P. Smith 4e414d8386 commits sourceforge patch #1407992 by neil.norwitz.
this fixes the bsddb db associate tests when compiled against
BerkeleyDB 3.3 thru 4.1.  4.2 thru 4.4 already passed and still
pass.
2006-01-24 19:55:02 +00:00
Gregory P. Smith 29602d2153 Support for BerkeleyDB 4.4 (tested against 4.4.20 as well as all the
way back thru 3.2).  This should be backported to the release24-maint
branch.
2006-01-24 09:46:48 +00:00
Neal Norwitz 1ac754fa10 Check return result from Py_InitModule*(). This API can fail.
Probably should be backported.
2006-01-19 06:09:39 +00:00
Neal Norwitz 40c6b47ca1 Fix errors on 64-bit platforms. Will backport 2006-01-05 05:43:35 +00:00
Jeremy Hylton af68c874a6 Add const to several API functions that take char *.
In C++, it's an error to pass a string literal to a char* function
without a const_cast().  Rather than require every C++ extension
module to put a cast around string literals, fix the API to state the
const-ness.

I focused on parts of the API where people usually pass literals:
PyArg_ParseTuple() and friends, Py_BuildValue(), PyMethodDef, the type
slots, etc.  Predictably, there were a large set of functions that
needed to be fixed as a result of these changes.  The most pervasive
change was to make the keyword args list passed to
PyArg_ParseTupleAndKewords() to be a const char *kwlist[].

One cast was required as a result of the changes:  A type object
mallocs the memory for its tp_doc slot and later frees it.
PyTypeObject says that tp_doc is const char *; but if the type was
created by type_new(), we know it is safe to cast to char *.
2005-12-10 18:50:16 +00:00
Neal Norwitz 8456235088 Get bsddb module to compile with version 3.2 of BSD DB. 2005-10-20 04:30:15 +00:00
Gregory P. Smith 8966d3de70 remove c++ style comment 2005-06-16 19:01:42 +00:00
Gregory P. Smith ac741c57d4 change set_bt_compare() callback comparison function to only take two
arguments (left, right) like any sane comparison function.  no need to
pass in the db object as an argument.
2005-06-06 17:31:32 +00:00