[PATCH] D37331: [ELF] Prevent crash with binary inputs with non-ascii file names
Rui Ueyama via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 31 13:54:58 PDT 2017
ruiu added a comment.
We had a discussion with Adrian and Reid, and the test should work on any locale and the pound sign will be passed to lld's `main()` as-is (as a two-byte UTF-8 character) because lld does not use wmain and we don't do something fancy with encoding conversions unlike clang does. So I think you can submit this test.
================
Comment at: ELF/InputFiles.cpp:934
for (size_t I = 0; I < S.size(); ++I)
- if (!isalnum(S[I]))
+ if (!isalnum(static_cast<unsigned char>(S[I])))
S[I] = '_';
----------------
isalnum might be locale-aware, so it is probably not safe to use here in the first place. Doing it manually (i.e. `'a' <= S[I] <= 'z' || 'A' <= S[I] <= 'Z' || '0' <= S[I] <= '0'` ) seems better.
https://reviews.llvm.org/D37331
More information about the llvm-commits
mailing list