<div dir="ltr">Hello everyone!<div><br></div><div>I've found weird lines of code in tools/libclang/CIndex.cpp file in clang sources. Function clang_tokenize holds the following lines:</div><div>  </div><div>  *Tokens = (CXToken *)malloc(sizeof(CXToken) * CXTokens.size());</div><div>  memmove(*Tokens, CXTokens.data(), sizeof(CXToken) * CXTokens.size());</div><div><br></div><div>Since malloc function can return null pointer and there are no checks for this case, memmove invocation leads to segmentation fault.</div><div><br></div><div>The same case can be found in tools/libclang/CXString.cpp file in function createDup:</div><div><br></div><div><div>  char *Spelling = static_cast<char *>(malloc(String.size() + 1));</div><div>  memmove(Spelling, String.data(), String.size());</div></div><div><br></div><div><br></div><div>Could somebody clarify me if I'm wrong?</div><div><br></div><div>Thanks,</div><div>Valeriy</div><div><br></div></div>