Skip to content
  • Sergei Trofimovich's avatar
    ProfilerReportJson.c: fix out-of-bounds access · 20c39b77
    Sergei Trofimovich authored
    
    
    Found by gcc-7.1 which reported build error as:
    
    rts/ProfilerReportJson.c:23:16: error:
         error: comparison between pointer and zero
           character constant [-Werror=pointer-compare]
             for (; str != '\0' && len > 0; str++) {
                        ^~
       |
    23 |     for (; str != '\0' && len > 0; str++) {
       |                ^
    
    Unfixed code in context:
    
    ```c
      static void escapeString(char const* str, char *out, int len)
      {
         len--; // reserve character in output for terminating NUL
         for (; str != '\0' && len > 0; str++) {
             char c = *str;
    ```
    
    The intent here is to process 'len' (if positive) or '\0'-terminator
    in 'str' but dereference was missing.
    
    Signed-off-by: default avatarSergei Trofimovich <slyfox@gentoo.org>
    20c39b77