ProfilerReportJson.c: fix out-of-bounds access
authorSergei Trofimovich <slyfox@gentoo.org>
Sun, 14 May 2017 19:21:50 +0000 (20:21 +0100)
committerSergei Trofimovich <slyfox@gentoo.org>
Sun, 14 May 2017 19:30:53 +0000 (20:30 +0100)
commit20c39b7743a242fce785e5c6507a8549dba7a8d2
tree6e921d00b83e79dcfbe2a6036b5a19ce57a20a33
parent2a971e35d96613183c6ebc81e1bd274b65cb0a1f
ProfilerReportJson.c: fix out-of-bounds access

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: Sergei Trofimovich <slyfox@gentoo.org>
rts/ProfilerReportJson.c