summaryrefslogtreecommitdiff
path: root/rts/ProfilerReportJson.c
diff options
context:
space:
mode:
authorSergei Trofimovich <slyfox@gentoo.org>2017-05-14 20:21:50 +0100
committerSergei Trofimovich <slyfox@gentoo.org>2017-05-14 20:30:53 +0100
commit20c39b7743a242fce785e5c6507a8549dba7a8d2 (patch)
tree6e921d00b83e79dcfbe2a6036b5a19ce57a20a33 /rts/ProfilerReportJson.c
parent2a971e35d96613183c6ebc81e1bd274b65cb0a1f (diff)
downloadhaskell-20c39b7743a242fce785e5c6507a8549dba7a8d2.tar.gz
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>
Diffstat (limited to 'rts/ProfilerReportJson.c')
-rw-r--r--rts/ProfilerReportJson.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/rts/ProfilerReportJson.c b/rts/ProfilerReportJson.c
index 3cf875e15b..a7869215f7 100644
--- a/rts/ProfilerReportJson.c
+++ b/rts/ProfilerReportJson.c
@@ -20,7 +20,7 @@
static void escapeString(char const* str, char *out, int len)
{
len--; // reserve character in output for terminating NUL
- for (; str != '\0' && len > 0; str++) {
+ for (; *str != '\0' && len > 0; str++) {
char c = *str;
if (c == '\\') {
if (len < 2) break;