X-Git-Url: https://git.distorted.org.uk/~mdw/catacomb-python/blobdiff_plain/963a61481edc7a83698b18b518bf20cd93d268a6..6140fbf7f12db17b61312571192eccc7d103e22b:/buffer.c diff --git a/buffer.c b/buffer.c index 8e4ece5..af4e1bf 100644 --- a/buffer.c +++ b/buffer.c @@ -7,7 +7,7 @@ * (c) 2005 Straylight/Edgeware */ -/*----- Licensing notice --------------------------------------------------* +/*----- Licensing notice --------------------------------------------------* * * This file is part of the Python interface to Catacomb. * @@ -15,12 +15,12 @@ * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * Catacomb/Python is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with Catacomb/Python; if not, write to the Free Software Foundation, * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. @@ -83,7 +83,7 @@ static int rbuf_pysegcount(PyObject *me, int *nn) { if (nn) *nn = BSZ(BUF_B(me)); return (1); } static int rbuf_pyreadbuf(PyObject *me, int seg, void **q) - { assert(seg == 0); *q = BBASE(BUF_B(me)); return (BSZ(BUF_B(me))); } + { assert(seg == 0); *q = BCUR(BUF_B(me)); return (BLEFT(BUF_B(me))); } static PyObject *rbmeth_skip(PyObject *me, PyObject *arg) { @@ -114,7 +114,7 @@ end: uint##n x; \ if (!PyArg_ParseTuple(arg, ":getu" #w)) goto end; \ if (buf_getu##w(BUF_B(me), &x)) BUFERR(); \ - return (getu32(x)); \ + return (getulong(x)); \ end: \ return (0); \ } @@ -186,7 +186,7 @@ static PyObject *rbmeth_getecpt(PyObject *me, PyObject *arg, PyObject *kw) end: return (0); } - + static PyObject *rbmeth_getecptraw(PyObject *me, PyObject *arg) { PyTypeObject *cobj = ecpt_pytype; @@ -236,6 +236,7 @@ static PyObject *rbget_offset(PyObject *me, void *hunoz) static int rbset_offset(PyObject *me, PyObject *x, void *hunoz) { size_t n; + if (!x) NIERR("__del__"); if (!convszt(x, &n)) goto end; if (n > BSZ(BUF_B(me))) VALERR("out of range"); BCUR(BUF_B(me)) = BBASE(BUF_B(me)) + n;