166f4a062Sdrh# 2006 July 26 2aa0fe807Sdrh# 3aa0fe807Sdrh# The author disclaims copyright to this source code. In place of 4aa0fe807Sdrh# a legal notice, here is a blessing: 5aa0fe807Sdrh# 6aa0fe807Sdrh# May you do good and not evil. 7aa0fe807Sdrh# May you find forgiveness for yourself and forgive others. 8aa0fe807Sdrh# May you share freely, never taking more than you give. 9aa0fe807Sdrh# 10aa0fe807Sdrh#*********************************************************************** 1166f4a062Sdrh# This file contains additional out-of-memory checks (see malloc.tcl) 1266f4a062Sdrh# added to expose a bug in out-of-memory handling for sqlite3_prepare16(). 13aa0fe807Sdrh# 14*eee4c8caSdrh# $Id: malloc7.test,v 1.5 2008/02/18 22:24:58 drh Exp $ 15aa0fe807Sdrh 16aa0fe807Sdrhset testdir [file dirname $argv0] 17aa0fe807Sdrhsource $testdir/tester.tcl 18*eee4c8caSdrhsource $testdir/malloc_common.tcl 19aa0fe807Sdrh 20aa0fe807Sdrh# Only run these tests if memory debugging is turned on. 21aa0fe807Sdrh# 22*eee4c8caSdrhif {!$MEMDEBUG} { 235a3032b3Sdrh puts "Skipping malloc7 tests: not compiled with -DSQLITE_MEMDEBUG..." 24aa0fe807Sdrh finish_test 25aa0fe807Sdrh return 26aa0fe807Sdrh} 27aa0fe807Sdrh 28aa0fe807Sdrh 29ed138fb3Sdrhdo_malloc_test malloc7-1 -sqlprep { 30aa0fe807Sdrh CREATE TABLE t1(a,b,c,d); 31aa0fe807Sdrh CREATE INDEX i1 ON t1(b,c); 32ed138fb3Sdrh} -tclbody { 33aa0fe807Sdrh set sql16 [encoding convertto unicode "SELECT * FROM sqlite_master"] 34aa0fe807Sdrh append sql16 "\00\00" 35aa0fe807Sdrh set nbyte [string length $sql16] 36ed138fb3Sdrh set ::STMT [sqlite3_prepare16 db $sql16 $nbyte DUMMY] 37aa0fe807Sdrh sqlite3_finalize $::STMT 38aa0fe807Sdrh} 39aa0fe807Sdrh 40aa0fe807Sdrh 41aa0fe807Sdrh# Ensure that no file descriptors were leaked. 42aa0fe807Sdrhdo_test malloc-99.X { 43aa0fe807Sdrh catch {db close} 44aa0fe807Sdrh set sqlite_open_file_count 45aa0fe807Sdrh} {0} 46aa0fe807Sdrh 47aa0fe807Sdrhputs open-file-count=$sqlite_open_file_count 48aa0fe807Sdrhfinish_test 49