Menu

QueryDoubleAttribute(const char*, float*) bug

Developer
levine
2005-04-28
2013-05-20
  • levine

    levine - 2005-04-28

    Firstly, tinyxml is really great stuff.

    I think i found a small bug.  If TiXmlElement::QueryDoubleAttribute(const char*, float*) fails to find the named attribute, the float is assigned a value from an uninitialized double.  If i am reading the documentation correctly, this is a bug and the correct behavior is to leave the float alone in that case.  Below is a patch.

    Thanks
    earl

    --- tinyxml-orig/tinyxml.h      2005-04-15 18:30:31.000000000 -0700
    +++ tinyxml/tinyxml.h   2005-04-27 16:49:36.791995728 -0700
    @@ -862,7 +862,7 @@
            int QueryDoubleAttribute( const char* name, float* value ) const {
                    double d;
                    int result = QueryDoubleAttribute( name, &d );
    -               *value = (float)d;
    +               if (result==TIXML_SUCCESS) *value = (float)d;
                    return result;
            }

     
    • Lee Thomason

      Lee Thomason - 2005-05-05

      Yep -- that's a bug. I added a Bug in the bug section.
      lee

       

Log in to post a comment.

MongoDB Logo MongoDB