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;
}
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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;
}
Yep -- that's a bug. I added a Bug in the bug section.
lee