Skip to content

Commit 7ff1c6f

Browse files
committed
v3.8.3 - Fix "applying zero offset to null pointer" error by UBSan
1 parent 0a08926 commit 7ff1c6f

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

nob.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* nob - v3.8.2 - Public Domain - https://github.com/tsoding/nob.h
1+
/* nob - v3.8.3 - Public Domain - https://github.com/tsoding/nob.h
22
33
This library is the next generation of the [NoBuild](https://github.com/tsoding/nobuild) idea.
44
@@ -2635,6 +2635,11 @@ NOBDEF Nob_String_View nob_sv_trim_left(Nob_String_View sv)
26352635
i += 1;
26362636
}
26372637

2638+
// Apparently if sv.data == 0 and i == 0 adding them
2639+
// together is an undefined behavior. According to
2640+
// clang's UndefinedBehaviorSanitizer at least.
2641+
if (i == 0) return sv;
2642+
26382643
return nob_sv_from_parts(sv.data + i, sv.count - i);
26392644
}
26402645

@@ -3028,6 +3033,7 @@ NOBDEF char *nob_temp_running_executable_path(void)
30283033
/*
30293034
Revision history:
30303035
3036+
3.8.3 (2026-07-14) Fix "applying zero offset to null pointer" error by clang's UndefinedBehaviorSanitizer
30313037
3.8.2 (2026-04-01) Fix the broken type safety of nob_cmd_append() (by @aalmkainzi)
30323038
3.8.1 (2026-04-01) Fix annoying clang warning
30333039
3.8.0 (2026-03-24) Add NOB_CLIT()

0 commit comments

Comments
 (0)