SEGGER_RTT_vprintf / SEGGER_RTT_printf string format NULL check

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • SEGGER_RTT_vprintf / SEGGER_RTT_printf string format NULL check

      Hi Segger Team,

      we're having software that passes printf format strings with %s in the format string, but the corresponding char * is NULL in same cases.

      As it is cumbersome to check the variadic arguments (va_args) values before passing them into SEGGER_RTT_vprintf we do patch the Segger RTT sources with an additional check right now.

      We also created a patch file:

      It would be nice, if this patch could get part of the official RTT release.


      Best regards
      Philipp Häfele
    • Hi mwb1100,

      wasn't aware of that behavior.

      Patch would then look something like that:

      Source Code: SEGGER_RTT_printf.c

      1. if(s == NULL) {
      2. _StoreChar(&BufferDesc, '(');
      3. _StoreChar(&BufferDesc, 'n');
      4. _StoreChar(&BufferDesc, 'u');
      5. _StoreChar(&BufferDesc, 'l');
      6. _StoreChar(&BufferDesc, 'l');
      7. _StoreChar(&BufferDesc, ')');
      8. break;
      9. }

      which is also totally ok :thumbup:

      The post was edited 1 time, last by ifmPhilipp: characters need to be in single quotes instead of double onces " => ' ().