U++ framework
Do not panic. Ask here before giving up.

Home » U++ Library support » U++ Core » Bug in Stream::Pack
Bug in Stream::Pack [message #40343] Mon, 22 July 2013 20:39 Go to previous message
Didier is currently offline  Didier
Messages: 740
Registered: November 2008
Location: France
Contributor
Hi,

Reading some code in 'Core/Stream.cpp' trying to understand what the '/' meant when serialising data, I stumbled on a bug:
'f' parameter gets overlapped by local variable, so this will not work as expected:


void    Stream::Pack(bool& a, bool& b, bool& c, bool& d, bool& e, bool& f, bool& g, bool& h) {
	if(IsError()) return;
	if(IsLoading()) {
		int f = Get();
		if(f < 0) LoadError();
		else {
			a = !!(f & 0x80);
			b = !!(f & 0x40);
			c = !!(f & 0x20);
			d = !!(f & 0x10);
			e = !!(f & 0x08);
			f = !!(f & 0x04);
			g = !!(f & 0x02);
			h = !!(f & 0x01);
		}
	}
	else {
		int f = 0;
		if(a) f |= 0x80;
		if(b) f |= 0x40;
		if(c) f |= 0x20;
		if(d) f |= 0x10;
		if(e) f |= 0x08;
		if(f) f |= 0x04;
		if(g) f |= 0x02;
		if(h) f |= 0x01;
		Put(f);
	}
}

[Updated on: Mon, 22 July 2013 20:39]

Report message to a moderator

 
Read Message
Read Message
Previous Topic: SetSysTime() or SetUtcTime()
Next Topic: Solve memory leak in OpenSSL 1.0.1c
Goto Forum:
  


Current Time: Tue May 26 20:18:17 GMT+2 2026

Total time taken to generate the page: 0.00566 seconds