mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-08 14:02:16 +03:00
Fix a memory leak that can follow an OOM error in a user-function that uses sqlite3_set_auxdata().
FossilOrigin-Name: 0185c4b689d18d66e6aa39b4a7bddc279e3c9d17
This commit is contained in:
14
manifest
14
manifest
@@ -1,5 +1,5 @@
|
|||||||
C Merge\sfts3-prefix-search\sbranch\swith\strunk.
|
C Fix\sa\smemory\sleak\sthat\scan\sfollow\san\sOOM\serror\sin\sa\suser-function\sthat\suses\ssqlite3_set_auxdata().
|
||||||
D 2011-06-14T11:50:09.808
|
D 2011-06-14T14:18:45.331
|
||||||
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
||||||
F Makefile.in c1d7a7f4fd8da6b1815032efca950e3d5125407e
|
F Makefile.in c1d7a7f4fd8da6b1815032efca950e3d5125407e
|
||||||
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
||||||
@@ -237,7 +237,7 @@ F src/update.c 80d77311d91ebc06b27149e75701f1b3e9356622
|
|||||||
F src/utf.c c53eb7404b3eb5c1cbb5655c6a7a0e0ce6bd50f0
|
F src/utf.c c53eb7404b3eb5c1cbb5655c6a7a0e0ce6bd50f0
|
||||||
F src/util.c 0f33bbbdfcc4a2d8cf20c3b2a16ffc3b57c58a70
|
F src/util.c 0f33bbbdfcc4a2d8cf20c3b2a16ffc3b57c58a70
|
||||||
F src/vacuum.c 05513dca036a1e7848fe18d5ed1265ac0b32365e
|
F src/vacuum.c 05513dca036a1e7848fe18d5ed1265ac0b32365e
|
||||||
F src/vdbe.c edfa3827d7a6fac2425bc10c0eb6e54342d2fa56
|
F src/vdbe.c 9eef9bb0d4a0de06cf904476eadf58395971e35a
|
||||||
F src/vdbe.h 5cf09e7ee8a3f7d93bc51f196a96550786afe7a1
|
F src/vdbe.h 5cf09e7ee8a3f7d93bc51f196a96550786afe7a1
|
||||||
F src/vdbeInt.h ad84226cc0adcb1185c22b70696b235a1678bb45
|
F src/vdbeInt.h ad84226cc0adcb1185c22b70696b235a1678bb45
|
||||||
F src/vdbeapi.c 0eeadc75e44a30efd996d6af6e7c5a2488e35be8
|
F src/vdbeapi.c 0eeadc75e44a30efd996d6af6e7c5a2488e35be8
|
||||||
@@ -555,7 +555,7 @@ F test/lock_common.tcl 0c270b121d40959fa2f3add382200c27045b3d95
|
|||||||
F test/lookaside.test 93f07bac140c5bb1d49f3892d2684decafdc7af2
|
F test/lookaside.test 93f07bac140c5bb1d49f3892d2684decafdc7af2
|
||||||
F test/main.test 9d7bbfcc1b52c88ba7b2ba6554068ecf9939f252
|
F test/main.test 9d7bbfcc1b52c88ba7b2ba6554068ecf9939f252
|
||||||
F test/make-where7.tcl 05c16b5d4f5d6512881dfec560cb793915932ef9
|
F test/make-where7.tcl 05c16b5d4f5d6512881dfec560cb793915932ef9
|
||||||
F test/malloc.test e56c9c3358da2c18385aea15a42dc970913986c2
|
F test/malloc.test 76017be66cec4375a4b4ea5c71245e27a9fe2d0b
|
||||||
F test/malloc3.test 4128b1e6ffa506103b278ad97af89174f310c7ca
|
F test/malloc3.test 4128b1e6ffa506103b278ad97af89174f310c7ca
|
||||||
F test/malloc4.test 957337613002b7058a85116493a262f679f3a261
|
F test/malloc4.test 957337613002b7058a85116493a262f679f3a261
|
||||||
F test/malloc5.test 4d16d1bb26d2deddd7c4f480deec341f9b2d0e22
|
F test/malloc5.test 4d16d1bb26d2deddd7c4f480deec341f9b2d0e22
|
||||||
@@ -945,7 +945,7 @@ F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c
|
|||||||
F tool/symbols.sh bc2a3709940d47c8ac8e0a1fdf17ec801f015a00
|
F tool/symbols.sh bc2a3709940d47c8ac8e0a1fdf17ec801f015a00
|
||||||
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
|
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
|
||||||
F tool/warnings.sh 347d974d143cf132f953b565fbc03026f19fcb4d
|
F tool/warnings.sh 347d974d143cf132f953b565fbc03026f19fcb4d
|
||||||
P 77f01578bb565d1bc884b374b68bae10ce34a084 aefd46dfae7e06fbaf4f2b9a86a7f2ac6927331e
|
P b1f9c1e0ac51cedfb05ac073a603343f6df865b5
|
||||||
R 84da75d7a3a06308ee488ec7371657d8
|
R 915dabb427b7d44a9631a4d5ac3ba884
|
||||||
U dan
|
U dan
|
||||||
Z 26ae4ebe97429ca9da8c05064a989555
|
Z 905532115e84db070a1615e7e8131374
|
||||||
|
@@ -1 +1 @@
|
|||||||
b1f9c1e0ac51cedfb05ac073a603343f6df865b5
|
0185c4b689d18d66e6aa39b4a7bddc279e3c9d17
|
19
src/vdbe.c
19
src/vdbe.c
@@ -1399,15 +1399,6 @@ case OP_Function: {
|
|||||||
db->lastRowid = lastRowid;
|
db->lastRowid = lastRowid;
|
||||||
(*ctx.pFunc->xFunc)(&ctx, n, apVal); /* IMP: R-24505-23230 */
|
(*ctx.pFunc->xFunc)(&ctx, n, apVal); /* IMP: R-24505-23230 */
|
||||||
lastRowid = db->lastRowid;
|
lastRowid = db->lastRowid;
|
||||||
if( db->mallocFailed ){
|
|
||||||
/* Even though a malloc() has failed, the implementation of the
|
|
||||||
** user function may have called an sqlite3_result_XXX() function
|
|
||||||
** to return a value. The following call releases any resources
|
|
||||||
** associated with such a value.
|
|
||||||
*/
|
|
||||||
sqlite3VdbeMemRelease(&ctx.s);
|
|
||||||
goto no_mem;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* If any auxiliary data functions have been called by this user function,
|
/* If any auxiliary data functions have been called by this user function,
|
||||||
** immediately call the destructor for any non-static values.
|
** immediately call the destructor for any non-static values.
|
||||||
@@ -1418,6 +1409,16 @@ case OP_Function: {
|
|||||||
pOp->p4type = P4_VDBEFUNC;
|
pOp->p4type = P4_VDBEFUNC;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( db->mallocFailed ){
|
||||||
|
/* Even though a malloc() has failed, the implementation of the
|
||||||
|
** user function may have called an sqlite3_result_XXX() function
|
||||||
|
** to return a value. The following call releases any resources
|
||||||
|
** associated with such a value.
|
||||||
|
*/
|
||||||
|
sqlite3VdbeMemRelease(&ctx.s);
|
||||||
|
goto no_mem;
|
||||||
|
}
|
||||||
|
|
||||||
/* If the function returned an error, throw an exception */
|
/* If the function returned an error, throw an exception */
|
||||||
if( ctx.isError ){
|
if( ctx.isError ){
|
||||||
sqlite3SetString(&p->zErrMsg, db, "%s", sqlite3_value_text(&ctx.s));
|
sqlite3SetString(&p->zErrMsg, db, "%s", sqlite3_value_text(&ctx.s));
|
||||||
|
@@ -894,6 +894,18 @@ ifcapable stat2&&utf16 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Test that if an OOM error occurs, aux-data is still correctly destroyed.
|
||||||
|
# This test case was causing either a memory-leak or an assert() failure
|
||||||
|
# at one point, depending on the configuration.
|
||||||
|
#
|
||||||
|
do_malloc_test 39 -tclprep {
|
||||||
|
sqlite3 db test.db
|
||||||
|
} -sqlbody {
|
||||||
|
SELECT test_auxdata('abc', 'def');
|
||||||
|
} -cleanup {
|
||||||
|
db close
|
||||||
|
}
|
||||||
|
|
||||||
# Ensure that no file descriptors were leaked.
|
# Ensure that no file descriptors were leaked.
|
||||||
do_test malloc-99.X {
|
do_test malloc-99.X {
|
||||||
catch {db close}
|
catch {db close}
|
||||||
|
Reference in New Issue
Block a user