antirez / sds

Simple Dynamic Strings library for C
BSD 2-Clause "Simplified" License
4.93k stars 480 forks source link

Potential undefined behavior when negating value in sdsll2str #90

Open ghost opened 6 years ago

ghost commented 6 years ago

When compiling with UndefinedBehaviorSanitizer and running the tests (CC=clang-6.0 CFLAGS='-fsanitize=undefined', the following error is raised:

[...]
6 - sdscatprintf() seems working in the base case: PASSED
sds.c:446:23: runtime error: negation of -9223372036854775808 cannot be represented 
in type 'long long'; cast to an unsigned type to negate this value to itself
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior sds.c:446:23 in
[...]