Skip to content

Commit 07388c5

Browse files
committed
slang_get_include_file - avoid strlen call
1 parent 448b6e3 commit 07388c5

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

gfx/drivers_shader/glslang_util.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@
2828
#include "glslang_util.h"
2929
#include "../../verbosity.h"
3030

31-
static char *slang_get_include_file(const char *line)
31+
static char *slang_get_include_file(const char *line, size_t len)
3232
{
3333
char *end = NULL;
34-
char *start = (char*)strchr(line, '\"');
34+
char *start = (char*)memchr(line, '\"', len + 1);
3535
if (!start)
3636
return NULL;
3737
start++;
38-
if (!(end = (char*)strchr(start, '\"')))
38+
if (!(end = (char*)memchr(start, '\"', len - (start - line))))
3939
return NULL;
4040
*end = '\0';
4141
return start;
@@ -226,7 +226,7 @@ bool glslang_read_shader_file(const char *path,
226226
if ( !strncmp("#include ", line, STRLEN_CONST("#include ")) || include_optional )
227227
{
228228
char include_path[PATH_MAX_LENGTH];
229-
char *include_file = slang_get_include_file(line);
229+
char *include_file = slang_get_include_file(line, strlen(line));
230230

231231
if (string_is_empty(include_file))
232232
{

0 commit comments

Comments
 (0)