Hello,

vdbemem.c (2004 May 26) reads at about line 650:

      if( pMem->enc==SQLITE_UTF8 && (flags & MEM_Term) ){
        assert( strlen(pMem->z)<=pMem->n );
        assert( pMem->z[pMem->n]==0 );
      }

First is tested if the length of the passed string is shorter or equal to
the passed number of bytes it's maximal allowed to be long. Secondly is
tested if the n-th byte of the string is a NULL-char

I don't recognize the actual need of the second assert.
if strlen(pMem->z) equals pMem->n then pMem->z[pMem->n] is of course equals
NULL
if strlen(pMem->z) was smaller than pMem->n then pMem->z[pMem->n] is  not 0
but there obviously must be a NULL char which instructs strlen to stop
counting characters.

The comment to the code reads, the check is done because of possible
erroneus databases.
I wonder what exactly is written into the database.
Are n bytes from pMem->z on written to the db? Is n written to the db too?
Is the actual length of the string at time of insertion written to the db?

Best,
Bernhard

Reply via email to