glcpp: Fix undefined behaviour in glcpp

Specifically, fix this error (which is covered in existing tests):

    ../src/compiler/glsl/glcpp/pp.c:198:28: runtime error: applying non-zero offset 1 to null pointer
    SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ../src/compiler/glsl/glcpp/pp.c:198:28 in

Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9669>
This commit is contained in:
Jesse Schwartzentruber
2021-03-11 11:08:36 -05:00
committed by Marge Bot
parent 95c58aacf8
commit 02492bea5f

View File

@@ -195,11 +195,11 @@ remove_line_continuations(glcpp_parser_t *ctx, const char *shader)
}
}
search_start = backslash + 1;
if (backslash == NULL)
break;
search_start = backslash + 1;
/* At each line continuation, (backslash followed by a
* newline), copy all preceding text to the output, then
* advance the shader pointer to the character after the