Hello Johannes, Johannes Brunen wrote: > inline > void ExceptionBinaryDataHandler::getValues(Real32 *value, > UInt32 size ) throw (ReadError) > { > get(value, size * sizeof(Real32)); > > #if BYTE_ORDER == LITTLE_ENDIAN > if(_networkOrder == true) > { > osgSwapMemy<sizeof(Real32)>(value, size); > } > #endif > } [SNIP - Real64 code] > IMHO the calling code might be victim of the same problem? I have not > checked for the calling code but what happens if the array *value is copied > after applying this function?
hm, these are for the reading direction, so the expectation is that values read by get(value, size * sizeof(Real32)) (which itself only deals with raw bytes) are in network byte order. Applying osgSwapMemory converts the values into proper floats for the host so the caller should be safe to treat them as such. At least that was my reasoning, it's quite possible that I'm missing something after staring at this for a while now... ;) > Second, in file OSGBaseFunctions.inl 3242, 3266, 3293, 3378,3396 and 3414 > after application of the patch: > > For example > > inline > OSG::Real32 osghtonf(OSG::Real32 src) > { > #if BYTE_ORDER == LITTLE_ENDIAN > UInt8 *p = reinterpret_cast<UInt8 *>(&src); > std::swap(p[0], p[3]); > std::swap(p[1], p[2]); > #endif > > return src; > } > > Same reasoning here. After changing the byte order the coying as reals is > not save. What do you think. Do I have a false reasoning here? yes, those are still unsafe, but they only exist for backwards compatibility and I don't see a way to make them safe without breaking compatibility - just changing the return value to UInt32 does not help, because callers will assign that UInt32 to a Real32 and simply round all their floats to integers... We can either remove these functions entirely (there should be no uses inside the OpenSG codebase) or make them only visible when OSGCOMPAT_ENABLE_DEPRECATED is defined. Cheers, Carsten ------------------------------------------------------------------------------ The Palm PDK Hot Apps Program offers developers who use the Plug-In Development Kit to bring their C/C++ apps to Palm for a share of $1 Million in cash or HP Products. Visit us here for more details: http://p.sf.net/sfu/dev2dev-palm _______________________________________________ Opensg-users mailing list Opensg-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/opensg-users