Page 1 of 1

[fixed]CPLYMeshFileLoader

Posted: Mon Jun 08, 2020 3:10 pm
by wolfgang
Hi,

since I updated my Irrlicht fork to the latest Irrlicht from the ogles branch I get an "invalid read" when testing with valgrind in the CPLYMeshFileLoader:

Here's the diff:

Code: Select all

@@ -571,7 +572,7 @@ c8* CPLYMeshFileLoader::getNextLine()
        StartPointer = LineEndPointer + 1;
 
        // crlf split across buffer move
-       if (StartPointer<EndPointer && *StartPointer == '\n')
+       if (*StartPointer == '\n')^M
        {
                *StartPointer = '\0';
                ++StartPointer;
@@ -582,7 +583,7 @@ c8* CPLYMeshFileLoader::getNextLine()
        while (pos < EndPointer && *pos && *pos != '\r' && *pos != '\n')
                ++pos;
 
-       if ( (pos+1) < EndPointer && ( *(pos+1) == '\r' || *(pos+1) == '\n') )
+       if ( pos < EndPointer && ( *(pos+1) == '\r' || *(pos+1) == '\n') )^M
        {
                *pos = '\0';
                ++pos;
 
I believe these changes are incorrect and should be reverted. After I restored the previous lines no errors occurred anymore. (And at least my meshed are still loaded correctly.)

Re: CPLYMeshFileLoader

Posted: Mon Jun 08, 2020 5:02 pm
by CuteAlien
This didn't seem to have gotten changed by us - looks like it's been like this from when it what added to Irrlicht (r2251). Thought on first look it makes sense to me to change it as it risks checking beyond end otherwise. Maybe something you fixed locally once before and we never knew about it?
Do you have a test .ply file for me for this? (edit: no worries if not, your solution definitely looks correct)

Re: CPLYMeshFileLoader

Posted: Wed Jun 10, 2020 2:15 pm
by wolfgang
Yes it's possible that I fixed this locally a long time ago and forgot about it.

Here's the ply: https://we.tl/t-Eb0I5DQLvr

Re: [fixed]CPLYMeshFileLoader

Posted: Fri Jun 12, 2020 8:55 pm
by CuteAlien
Thanks. It's fixed now in svn trunk r6113 and svn ogl-es branch r6117.