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

Home » U++ Library support » U++ Core » InFilterStream::Out() is buggy: a possible bugfix
InFilterStream::Out() is buggy: a possible bugfix [message #56758] Mon, 12 April 2021 02:54 Go to previous message
zsolt is currently offline  zsolt
Messages: 705
Registered: December 2005
Location: Budapest, Hungary
Contributor
The problem is, that it does not set some variables in the base class at a point.
The correct code would be:
void InFilterStream::Out(const void *p, int size)
{
	const byte *s = (byte *)p;
	if(todo) {
		dword sz = min(todo, (dword)size);
		memcpy8(t, s, sz);
		t += sz;
		s += sz;
		todo -= sz;
		size -= sz;
		pos += sz;
	}
	if(size) {
		int l = buffer.GetCount();
		buffer.SetCountR(l + size);
		memcpy8(buffer.begin() + l, s, size);
		Stream::buffer = ptr = buffer.begin();
		rdlim = buffer.end();
	}
	WhenOut();
}


The added two lines are:
+		Stream::buffer = ptr = buffer.begin();
+		rdlim = buffer.end();


I hope, it will not break any other things in code.

I found it, when I wanted to use that as a gzip input filter to read from an uncompressed stream in gzipped format:
class MyGzipInStream : public InFilterStream {
	Zlib         z;

public:
	void Open(Stream& in)    { Set(in, z); z.Compress(); }
	Zlib& GetZlib()           { return z; }
	MyGzipInStream()    { z.GZip().Header(); }
	~MyGzipInStream()   { Close(); }
};

[Updated on: Wed, 14 April 2021 01:29]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Any Example of Inverse a Matrix in U++?
Next Topic: Public access to Argv0__[]
Goto Forum:
  


Current Time: Sat Sep 05 12:21:51 GMT+2 2026

Total time taken to generate the page: 0.00571 seconds