From: Peter Schneider Date: Wed, 25 Jul 2012 13:26:23 +0000 (+0200) Subject: fixed NULL-pointer dereference in the ftdi_error_return(code, str) macro that occures... X-Git-Tag: v1.0rc1~25 X-Git-Url: http://developer.intra2net.com/git/?a=commitdiff_plain;h=b0a504597b70c3702742a816e6bf1fcc7cfc6d53;p=libftdi fixed NULL-pointer dereference in the ftdi_error_return(code, str) macro that occures when it is called because of a ftdi == NULL check Hi, as we just performed a Cppcheck run upon our project including the libftdi sources it found a possible null-pointer dereference when calling the ftdi_error_return(code, str) macro after the ftdi==NULL check. Fix for this bug: --- 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);