Hi Robert -- Sorry, looks like your forward to me got buried in my inbox. Fortunately I saw this one.

I'm not as familiar with the loader code as I once was. It was originally written by Brede, of course, and I haven't looked at it closely since I wrote the exporter 4 or 5 years ago. I have no idea why it's using strings to parse the palette record.

I'd say that empty OpenFlight files are pretty corner-case (no one has ever ran into this issue until now), so special-casing it in such a way that doesn't interfere with the mainstream code path would probably be the best approach. I didn't look at the patch, but Nathan's description of it sounds like the right thing to do.

Hope this helps,
   -Paul


On 3/29/2012 2:00 AM, Robert Osfield wrote:
Hi Nathan,

You submission did make it on to osg-submissions and I reviewed it but
wasn't clear on the intention of original code and the wasn't
comfortable with the modification so I posted a query about the
original function to Paul Martz but haven't yet had a reply.

Robert.

On 28 March 2012 22:20, Nathan Monteleone<[email protected]>  wrote:

nbmont wrote:
Hi,

Saw this in vs2010 when I tried to load an .flt file freshly made in creator 
but with nothing in it.  You get a string index out of range exception in 
PaletterRecords.cpp, line 73 where it does

         uint32 paletteSize = in.readUInt32();

         // Entries in vertex pool found by offset from start of this record.
         const int RECORD_HEADER_SIZE = 4;
         const int OFFSET = RECORD_HEADER_SIZE+sizeof(paletteSize);

         std::string buffer(paletteSize,'\0');
         in.read(&buffer[OFFSET], paletteSize-OFFSET);

The problem is that for an empty vertex palette, OFFSET equals paletteSize, so 
OFFSET is past the end of buffer.  This code normally doesn't have a problem 
because it's reading 0 bytes into this location anyway, but iterator debugging 
catches the out of range index.

A simple if (OFFSET<  buffer.size()) fixes the problem.  I attached an amended 
file with the fix, plus a test model that reproduces the problem.

I know it's a little silly to be loading empty .flt files, but I can't control 
what people try to load and *technically* it's a valid file.

Hope that's helpful -- thanks for all the wonderful work on OSG.

Nathan


bump -- did this make it to the e-mail list?

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=46657#46657





_______________________________________________
osg-submissions mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org
_______________________________________________
osg-submissions mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org


_______________________________________________
osg-submissions mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org

Reply via email to