System.Data.SQLite

Login
This project makes use of Eagle, provided by Mistachkin Systems.
Eagle: Secure Software Automation
Ticket Hash: 201128cc8893e3d92ddf1b3e1e89a5f653f006ee
Title: SQLite3.GetParamValueBytes optimization
Status: Closed Type: Code_Defect
Severity: Minor Priority: Immediate
Subsystem: Integration_Via_PInvoke Resolution: Fixed
Last Modified: 2011-07-07 04:34:49
Version Found In:
Description:
Current:

      nlen = UnsafeNativeMethods.sqlite3_value_bytes(p);
      ptr = UnsafeNativeMethods.sqlite3_value_blob(p);
      if (bDest == null) return nlen;


Need:

      nlen = UnsafeNativeMethods.sqlite3_value_bytes(p);
      if (bDest == null) return nlen;

      if (nCopied + nStart > bDest.Length) nCopied = bDest.Length - nStart;
      if (nCopied + nDataOffset > nlen) nCopied = nlen - nDataOffset;

      if (nCopied > 0) {
        ptr = UnsafeNativeMethods.sqlite3_value_blob(p);
        Marshal.Copy((IntPtr)(ptr.ToInt64() + nDataOffset), bDest, nStart, nCopied);
      }
      else nCopied = 0;

<hr /><i>mistachkin added on 2011-07-05 10:18:17 UTC:</i><br />
Fixed in [3e063f371f].


<hr /><i>anonymous added on 2011-07-05 13:55:47 UTC:</i><br />
1)
if (nCopied > 0) {
  IntPtr ptr = UnsafeNativeMethods.sqlite3_value_blob(p);
  ...

2)
ptr.ToInt32() -> ptr.ToInt64()


<hr /><i>mistachkin added on 2011-07-07 02:41:02 UTC:</i><br />
Fixed, see check-in [f09f0e8ea1].


<hr /><i>mistachkin added on 2011-07-07 04:19:24 UTC:</i><br />
Added test case, see check-in [a290d2c1a5].