From: drh Date: Wed, 18 Feb 2004 16:57:23 +0000 (+0000) Subject: Fix a memory leak that occurs if you call sqlite_interrupt() on a query X-Git-Tag: version-3.6.10~4820 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9cbe7ca7db32179f096b8365aca826722ddc9050;p=thirdparty%2Fsqlite.git Fix a memory leak that occurs if you call sqlite_interrupt() on a query using aggregate functions where the aggregate function returns a string longer than 32 characters. (CVS 1248) FossilOrigin-Name: 2c1e74e58a702fd2be954467a12e69a33b252831 --- diff --git a/manifest b/manifest index b1dc18ae51..5ca22d344c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Begin\supdating\sthe\sarchitecture\sdescription\sto\sbetter\sdescribe\show\sthings\nare\scurrently\sput\stogether.\s(CVS\s1247) -D 2004-02-18T16:56:32 +C Fix\sa\smemory\sleak\sthat\soccurs\sif\syou\scall\ssqlite_interrupt()\son\sa\squery\nusing\saggregate\sfunctions\swhere\sthe\saggregate\sfunction\sreturns\sa\sstring\nlonger\sthan\s32\scharacters.\s(CVS\s1248) +D 2004-02-18T16:57:23 F Makefile.in cfd75c46b335881999333a9e4b982fa8491f200b F Makefile.linux-gcc b86a99c493a5bfb402d1d9178dcdc4bd4b32f906 F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd @@ -64,7 +64,7 @@ F src/vacuum.c d9e80c2b36ee1f623dbf1bdf3cedad24a23f87ac F src/vdbe.c e1825bcb40da6dd8429b24f404dc31265face31e F src/vdbe.h b9f6f1b5f9d1bfceb8bda5e396877ba584c4519c F src/vdbeInt.h af83bd700b1cc10b9cad2af146002927e0d421c9 -F src/vdbeaux.c 11f1fa94869870ebd8338ada489e64647414268b +F src/vdbeaux.c 9f8c7eeeeabd5c7b7fd10adb106212651c53796a F src/where.c 1302d728bd338c237e6a8282e4e3eadbbdf11e45 F test/all.test 569a92a8ee88f5300c057cc4a8f50fbbc69a3242 F test/attach.test ba8261d38da6b6a7d4f78ec543c548c4418582ef @@ -94,7 +94,7 @@ F test/in.test 0de39b02ceeca90993b096822fb5a884661c5b47 F test/index.test 9295deefbdb6dedbe01be8905f0c448fe5bd4079 F test/insert.test a17b7f7017097afb2727aa5b67ceeb7ab0a120a1 F test/insert2.test c288375a64dad3295044714f0dfed4a193cf067f -F test/interrupt.test 46bc6ad9ba9032bee144382ced719d5e010406c2 +F test/interrupt.test 9142ce4448605127640eda5e283952f75f67ed91 F test/intpkey.test 9320af48415c594afd4e15f8ef0daa272e05502e F test/ioerr.test 5dbaf09f96b56ee01cf3edd762b96eb4ad2c9ca4 F test/join.test 9ef6aabaac9de51d5fc41e68d1f4355da05a84cd @@ -186,7 +186,7 @@ F www/sqlite.tcl 3c83b08cf9f18aa2d69453ff441a36c40e431604 F www/tclsqlite.tcl b9271d44dcf147a93c98f8ecf28c927307abd6da F www/vdbe.tcl 9b9095d4495f37697fd1935d10e14c6015e80aa1 F www/whentouse.tcl a8335bce47cc2fddb07f19052cb0cb4d9129a8e4 -P e4c8b1c3aa9d288f518c6394187354e6fa18978e -R 9c0d8e2f5a853263270cb382693ec393 +P 062ecc1368d6bb6d15da31e8d6f5953e8f5628b9 +R 4707d2271ed24781339bd9c9a8a6f215 U drh -Z 385597eeec31fcd3b70006a6664f87b7 +Z 2d66e4ab4824193ca7a53544a03df80f diff --git a/manifest.uuid b/manifest.uuid index 44b0a48c37..450fb8da10 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -062ecc1368d6bb6d15da31e8d6f5953e8f5628b9 \ No newline at end of file +2c1e74e58a702fd2be954467a12e69a33b252831 \ No newline at end of file diff --git a/src/vdbeaux.c b/src/vdbeaux.c index 93b95766ac..ee3163b06d 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -660,6 +660,9 @@ void sqliteVdbeAggReset(Agg *pAgg){ if( pMem->z!=0 && pMem->z!=pMem->zShort ){ sqliteFree(pMem->z); } + if( ctx.s.flags & MEM_Dyn ){ + sqliteFree(ctx.s.z); + } }else if( pMem->flags & MEM_Dyn ){ sqliteFree(pMem->z); } diff --git a/test/interrupt.test b/test/interrupt.test index e9e5934d5c..456cf48a17 100644 --- a/test/interrupt.test +++ b/test/interrupt.test @@ -11,7 +11,7 @@ # This file implements regression tests for SQLite library. The # focus of this script is the sqlite_interrupt() API. # -# $Id: interrupt.test,v 1.3 2004/02/18 01:31:54 drh Exp $ +# $Id: interrupt.test,v 1.4 2004/02/18 16:57:23 drh Exp $ set testdir [file dirname $argv0] @@ -146,13 +146,11 @@ for {set i 1} {$i<50} {incr i 5} { # will try to reproduce it here: # execsql { - UPDATE t1 SET b=round((100-rowid)/10); + CREATE TABLE t2(a,b,c); + INSERT INTO t2 SELECT round(a/10), randstr(50,80), randstr(50,60) FROM t1; } set sql { - SELECT sum(a.a), max(a.a), min(b.a), a.b - FROM t1 AS a, t1 AS b - WHERE b.rowid=a.b - GROUP BY 4 ORDER BY 1; + SELECT max(min(b,c)), min(max(b,c)), a FROM t2 GROUP BY a ORDER BY a; } set sqlite_interrupt_count 1000000 execsql $sql @@ -160,12 +158,7 @@ set max_count [expr {1000000-$sqlite_interrupt_count}] for {set i 1} {$i<$max_count-5} {incr i 1} { do_test interrupt-4.$i.1 { set ::sqlite_interrupt_count $::i - catchsql { - SELECT sum(a.a), max(a.a), min(b.a), a.b - FROM t1 AS a, t1 AS b - WHERE b.rowid=a.b - GROUP BY 4 ORDER BY 1; - } + catchsql $sql } {1 interrupted} }