c4_Bytes destructor causes memory deallocation failure

<[email protected]>
Newsgroups gmane.comp.db.metakit
Message-ID <[email protected]>
Hi,

I have another problem with c4_Bytes. It seems that
the destructor in some cases deletes the wrong memory.

The following code works as release build, but as 
debug build it fails in _CrtIsValidHeapPointer.

Curiously enough it works correctly as long as the
length is <= 16?

#include "mk4.h"
#include <string>
#include <iostream>
using namespace std;

void main() {
	c4_Storage storage("datafile.kit", true);
	c4_View v = storage.GetAs("v[b:B]");

	v.Add(c4_Row());
	c4_BytesProp pBytes("b");

	string teststring("Hello, this is a test!"); //
len=22
	c4_Bytes textbytes(teststring.data(),
teststring.length());

	pBytes(v[0]).Modify(textbytes, 0, textbytes.Size());

	// Works with up-to len=16
	c4_Bytes newbytes = pBytes(v[0]).Access(0, 16);
	//cout << string((const char *)newbytes.Contents(),
newbytes.Size()) << endl;

	newbytes = pBytes(v[0]).Access(0, 17);
	//cout << string((const char *)newbytes.Contents(),
newbytes.Size()) << endl;
}

Best Regards,
  Arto Stimms


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
_____________________________________________
Metakit mailing list  -  [email protected]
http://www.equi4.com/mailman/listinfo/metakit
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.