[fixed]CPLYMeshFileLoader

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
wolfgang
Posts: 9
Joined: Mon Jul 01, 2019 8:14 am

[fixed]CPLYMeshFileLoader

Post 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.)
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: CPLYMeshFileLoader

Post 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)
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
wolfgang
Posts: 9
Joined: Mon Jul 01, 2019 8:14 am

Re: CPLYMeshFileLoader

Post 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
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: [fixed]CPLYMeshFileLoader

Post by CuteAlien »

Thanks. It's fixed now in svn trunk r6113 and svn ogl-es branch r6117.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Post Reply