Fix a critical bug using strlen that results in unspecified behavior between different compiler, namely gcc & llvm