Skip to content

Commit

Permalink
Make hashes use unsigned
Browse files Browse the repository at this point in the history
This avoids undefined behaviour.  Fixes #274
  • Loading branch information
rogerbinns committed Oct 17, 2019
1 parent e77fa2a commit d4d16c2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
6 changes: 4 additions & 2 deletions doc/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ Change History
**************
.. currentmodule:: apsw

3.30.0-r1
3.30.1-r1
=========

Added constants:

* SQLITE_DBCONFIG_ENABLE_VIEW
* SQLITE_DBCONFIG_ENABLE_VIEW

Updated of SQL statements (:issue:`274`)

3.29.0-r1
=========
Expand Down
4 changes: 2 additions & 2 deletions src/apswbuffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,10 @@ APSWBuffer_fini(void)
they can also use a hash seed which alters the value. There is no need
for this hash and strings/bytes etc be the same, but usually they are. We
add an extra 1 to put APSWBuffer into a different hash bucket. */
static long
static Py_hash_t
APSWBuffer_hash(APSWBuffer *self)
{
long hash;
Py_hash_t hash;
unsigned char *p;
Py_ssize_t len;

Expand Down
4 changes: 4 additions & 0 deletions src/pyutil.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
typedef int Py_ssize_t;
#endif

#if PY_VERSION_HEX < 0x03020000
typedef unsigned long Py_hash_t;
#endif

/* Python 2.3 doesn't have these */
#ifndef Py_RETURN_NONE
#define Py_RETURN_NONE return Py_INCREF(Py_None), Py_None
Expand Down

0 comments on commit d4d16c2

Please sign in to comment.