OBJ loader in Irrlicht 1.1 sometimes crashes (FIX)

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
alc
Posts: 31
Joined: Sun Jun 25, 2006 10:59 pm
Location: Denmark

OBJ loader in Irrlicht 1.1 sometimes crashes (FIX)

Post by alc »

I've seen a couple of threds on the OBJ loader regarding crashes and exceptions of various kinds. I had the same problem, and tracked it down to a sign issue in the MTL file reader.

The fix (well, it works for me) is to replace line 634 in COBJMeshFileLoader.cpp

Code: Select all

while (isspace(buf[++i])) ;
with

Code: Select all

while (isspace((unsigned char)buf[++i])) ;
Apparently, when the buf[] is negative, the isspace function stops at an ASSERT somewhere, and the application crashes. Forcing it possitive seems to solve the problem. I guess that this error only shows up in certain cases, i.e. whenever the first character beyond the file buffer just happens to be 128+ (which may explain why this error hasn't been found in testing the loader).

I've used svn version 194 (but I haven't committed this, as I'm not sure if that's the right procedure, or indeed if I'm even allowed to do so).
CuteAlien
Admin
Posts: 9716
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

Another problem is in readMTL:

line 326:

Code: Select all

while(pBufPtr && (pBufPtr-pBuf<=filesize))
should be:

Code: Select all

while(pBufPtr && (pBufPtr-pBuf<filesize))
< instead of <=
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Fixed in revision 196. Thanks for pointing me to it.
I did not dare to change the complete code to u8 which might have been a better idea, but I don't know about side effects. So if this works it's ok for now. And no, you don't have write access to SVN :o
Post Reply