Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Core » Bug in Stream::Pack
Bug in Stream::Pack [message #40343] Mon, 22 July 2013 20:39 Go to next message
Didier is currently offline  Didier
Messages: 680
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

Re: Bug in Stream::Pack [message #40346 is a reply to message #40343] Mon, 22 July 2013 22:16 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Ops, that is really stupid... thanks, fixed.

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


Current Time: Thu Apr 25 22:51:15 CEST 2024

Total time taken to generate the page: 0.04489 seconds