mirror of
https://github.com/nigels-com/glew.git
synced 2024-11-22 05:45:07 +00:00
Remove broken end of string checks in _glewStrSame
I think this code tried to check for a zero terminated null byte, but it actually just checked if the address of the corresponding character is non-zero, which is always true. These broken checks are simply dropped because the following code assumes that the string `b` doesn't include a null byte and all call sites already pass the length of the string without counting the null byte. This bug was found by gcc 12.1 which emits a warning on this kind of code. Now glew builds without any warnings using gcc 12.1. See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102103 for the corresponding issue.
This commit is contained in:
parent
2c4c183c34
commit
37e6144802
@ -221,7 +221,7 @@ static GLboolean _glewStrSame1 (const GLubyte** a, GLuint* na, const GLubyte* b,
|
|||||||
if(*na >= nb)
|
if(*na >= nb)
|
||||||
{
|
{
|
||||||
GLuint i=0;
|
GLuint i=0;
|
||||||
while (i < nb && (*a)+i != NULL && b+i != NULL && (*a)[i] == b[i]) i++;
|
while (i < nb && (*a)[i] == b[i]) i++;
|
||||||
if(i == nb)
|
if(i == nb)
|
||||||
{
|
{
|
||||||
*a = *a + nb;
|
*a = *a + nb;
|
||||||
@ -237,7 +237,7 @@ static GLboolean _glewStrSame2 (const GLubyte** a, GLuint* na, const GLubyte* b,
|
|||||||
if(*na >= nb)
|
if(*na >= nb)
|
||||||
{
|
{
|
||||||
GLuint i=0;
|
GLuint i=0;
|
||||||
while (i < nb && (*a)+i != NULL && b+i != NULL && (*a)[i] == b[i]) i++;
|
while (i < nb && (*a)[i] == b[i]) i++;
|
||||||
if(i == nb)
|
if(i == nb)
|
||||||
{
|
{
|
||||||
*a = *a + nb;
|
*a = *a + nb;
|
||||||
@ -253,7 +253,7 @@ static GLboolean _glewStrSame3 (const GLubyte** a, GLuint* na, const GLubyte* b,
|
|||||||
if(*na >= nb)
|
if(*na >= nb)
|
||||||
{
|
{
|
||||||
GLuint i=0;
|
GLuint i=0;
|
||||||
while (i < nb && (*a)+i != NULL && b+i != NULL && (*a)[i] == b[i]) i++;
|
while (i < nb && (*a)[i] == b[i]) i++;
|
||||||
if (i == nb && (*na == nb || (*a)[i] == ' ' || (*a)[i] == '\n' || (*a)[i] == '\r' || (*a)[i] == '\t'))
|
if (i == nb && (*na == nb || (*a)[i] == ' ' || (*a)[i] == '\n' || (*a)[i] == '\r' || (*a)[i] == '\t'))
|
||||||
{
|
{
|
||||||
*a = *a + nb;
|
*a = *a + nb;
|
||||||
|
Loading…
Reference in New Issue
Block a user