<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/126334>126334</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
In UnsafeBufferUsage.cpp is getEndCharLoc(...) missing an assertion
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
shafik
</td>
</tr>
</table>
<pre>
Static analysis points out that on this line:
https://github.com/llvm/llvm-project/blob/12a154a94a9c2f6f0690adc7302da9c9e47ec806/clang/lib/Analysis/UnsafeBufferUsage.cpp#L2348
`Lexer::MeasureTokenLength` can return `0` and on the subsequent line `TkLen - 1` will end up as max unsigned which does not look like the code would deal with that gracefully.
This was brought in via https://github.com/llvm/llvm-project/commit/63413015099bc8aaa45cba7551e8fe432b2b795f
It looks like the assumption is that this will never return zero, if that is the case there should be an assertion, something like `assert(TkLen !=0);` to document this invariant.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJyUk8uO2zgQRb-G3hRiUKWHpYUW3ckYCOBZTecDSmRJ4pgmPXzY6fn6AaUOMotsAgjQq3h576kixWgWxzyK9lW0Xw6U0-rDGFeazfUwef0-_pUoGQXkyL5HE-HujUsRfE6QVkrgHaTVRLDGsahfhCzXmtI9ljc8CzwvJq15Oip_E3i29vHj9uke_N-sksDzZP0k8FwhVW1DQ0ODwrmbZTdI0upUS9Q0qIGbE6tedgLPypJbipApC18-7Ak8f3ORZn7N88zhW6SFj-p-F1hfsG763Z7o5IW_cygO65c_mWIO_Oav7C7slrSKToIiB4FTDg5EJ2X5RE7vcRliniL_k9mlLXgpebte2MEnqErp01gL7DTkO1CEG32H7DbWGp6rUStozxGcT2C9v4I1V96EldcMT5-tBs1k4WnSuoNeAimes7Xvxz3FW8H-pAhT8HlZExgHD0Pw2_CVv91Meejqpqpl1cphmFRPRE2rJjq1bcX9zE2NE06noZ33_b_u3uNP8xRjvt2T8Q5M3F1vs7HRcPzg8APpvxy8wM9g5r1sK2dQFDelwBDXDcLEQK4Icyi6ZU30N06rccu-sejk_ltgv_dAYCXqL1LgIOrX0o3kQXuVb6VdmyHjHhQMufSBEg56rPVQD3TgsTrV_dDLDvGwjgoVN0rPsj9xO5HWTS9p1nOl-kpOw-lgRpTYSpS9xEoiHgdSGjWzrGvJiLNoJN_I2GOhfvRhOZgYM48VdnXdHCxNbON2ABE_hhrLWQzj1qYpL1E00pqY4k-JZJLl8auDX057wblw-sPpzyuFi1cC--PxKHCAm4mxoPs_1EMOdvztqdlSxO3QbkEeI_4XAAD__9NaaNc">