libftdi Archives

Subject: Re: [PATCH] fixed NULL-pointer dereference in the ftdi_error_return(code, str) macro that occures when it is called because of a ftdi == NULL check

From: Thomas Jarosch <thomas.jarosch@xxxxxxxxxxxxx>
To: libftdi@xxxxxxxxxxxxxxxxxxxxxxx
Cc: Peter Schneider <pitpompej@xxxxxxxx>
Date: Sat, 28 Jul 2012 18:05:25 +0200
On Wednesday, 25. July 2012 15:26:23 Peter Schneider wrote:
> Fix for this bug:
> 
> ---
>  src/ftdi.c |    5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/src/ftdi.c b/src/ftdi.c
> index 07687e8..5a3d44e 100644
> --- a/src/ftdi.c
> +++ b/src/ftdi.c
> @@ -39,7 +39,10 @@
>  #include "ftdi_version_i.h"
> 
>  #define ftdi_error_return(code, str) do {  \
> -        ftdi->error_str = str;             \
> +        if ( ftdi )                        \
> +            ftdi->error_str = str;         \
> +        else                               \
> +            fprintf(stderr, str);          \
>          return code;                       \
>     } while(0);

Thanks, applied. I've also backported the fix for libftdi-0.x.

Thomas


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

Current Thread