libftdi Archives

Subject: Re: [PATCH] Use a separate Py_ssize_t var instead of casting an int pointer as a Py_ssize_t pointer.

From: Thomas Jarosch <thomas.jarosch@xxxxxxxxxxxxx>
To: libftdi@xxxxxxxxxxxxxxxxxxxxxxx
Cc: Jordan Rupprecht <rupprecht@xxxxxxxxxx>
Date: Mon, 5 Nov 2018 22:28:12 +0100
Hi Jordan,

On 9/20/18 8:05 PM, Jordan Rupprecht wrote:
> Casting is fine if Py_ssize_t == int, but not when Py_ssize_t == long.
> 
> Signed-off-by: Jordan Rupprecht <rupprecht@xxxxxxxxxx>
> ---
>  python/ftdi1.i | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/python/ftdi1.i b/python/ftdi1.i
> index 93793f8..d53ebb0 100644
> --- a/python/ftdi1.i
> +++ b/python/ftdi1.i
> @@ -22,11 +22,13 @@ inline PyObject* charp2str(const char *v_, long len)
>  inline char * str2charp_size(PyObject* pyObj, int * size)
>  {
>    char * v_ = 0;
> +  Py_ssize_t len = 0;
>  #if PY_MAJOR_VERSION >= 3
> -  PyBytes_AsStringAndSize(pyObj, &v_, (Py_ssize_t*)size);
> +  PyBytes_AsStringAndSize(pyObj, &v_, &len);
>  #else
> -  PyString_AsStringAndSize(pyObj, &v_, (Py_ssize_t*)size);
> +  PyString_AsStringAndSize(pyObj, &v_, &len);
>  #endif
> +  *size = len;
>    return v_;
>  }
>  %}

patch applied, thanks Jordan!

Were you hit by this during runtime?


@all: One patch from Uwe Bonnes and one from Eric L. Schott are still
outstanding. I have to take care of them on another day,
but they won't be forgotten.

Cheers,
Thomas

--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to libftdi+unsubscribe@xxxxxxxxxxxxxxxxxxxxxxx   

Current Thread