Opened 16 years ago
Closed 16 years ago
#1549 closed Bug (Fixed)
Call to _SQLite_Escape causes exception abend in certain circumstances
| Reported by: | Owned by: | J-Paul Mesnage | |
|---|---|---|---|
| Milestone: | 3.3.7.0 | Component: | Standard UDFs |
| Version: | 3.3.6.0 | Severity: | None |
| Keywords: | SQLite _SQLite_Escape dll | Cc: |
Description
I have a program which parses html pages and inserts the data into a SQLite database. In certain circumstances, when I parse sections of text, _SQLite_Escape abends with an exception error. AutoIt reports an Exit Code of -1073741819.
Program Code:
#include <IE.au3> #include <SQLite.au3> #include <SQLite.dll.au3> _SQLite_Startup () $lawWindow = _IECreate () _IENavigate($lawWindow, "file://I:\laws\testbadfile.htm", 1) $fullText = _IEBodyReadText ($lawWindow) $escapedText = _SQLite_Escape($fullText)
Two files are attached, one which does not produce the error (testgoodfile.htm) and one which does produce the error (testbadfile.htm). Be sure that you change the path to the file in the _IENavigate function call.
The SQLite.au3 version included with AutoIt 3.3.3.0 works fine on both files and all others I have seen.
Any SQLite.au3 versions includedwith AutoIt 3.3.4.0 or later do not work on both files and the success is intermitant.
I believe the error is happening in the function
_ _SQLite_Utf8StructToString during this call:
$aResult = DllCall("Kernel32.dll", "int", "MultiByteToWideChar", "uint", 65001, "dword", 0, "ptr", DllStructGetPtr($tText), "int", -1, _
"wstr", DllStructGetPtr($tWstr), "int", $aResult[0])
Attachments (1)
Change History (5)
by , 16 years ago
| Attachment: | testfiles.zip added |
|---|
comment:1 by , 16 years ago
Thank you for reporting. I'll look at this more closely.
In the meantime, you can use the following functions, that may someday replace _SQLite_Escape and _SQLite_Encode.
Func X($s)
Return ("'" & StringReplace($s, "'", "''", 0, 1) & "'")
EndFunc ;==>X
Func XX($s)
Return (",'" & StringReplace($s, "'", "''", 0, 1) & "'")
EndFunc ;==>XX
Func Y($s)
Return ("X'" & Hex($s) & "'")
EndFunc ;==>Y
Func YY($s)
Return (",X'" & Hex($s) & "'")
EndFunc ;==>YY
X($str) is _SQLite_Escape($str)
Y($bin) is _SQLite_Encode($bin)
XX and YY are useful for subsequent parameters: they prepend a comma to output of X() and Y().
This makes the use very compact and readable:
$err = _SQLite_Exec($hdl, "insert into T (a, b, c) values ("&X($text1)&XX($str2)&XX($s3)&");")
or using another style
$err = _SQLite_Exec($hdl, "insert into T (a, b, c) values (" & _
X($text1) & _
XX($str2) & _
XX($s3) & _
");")
These short function names are mine, but if they ever make it in the SQLite UDF they will likely have less ambiguous names and include error checking...
comment:3 by , 16 years ago
I assume you mean 3.3.0.0 and not 3.3.3.0. I need to do some archeology to found out when the regression occured.
Anyway will be fixed next beta
Thanks
comment:4 by , 16 years ago
| Milestone: | → 3.3.7.0 |
|---|---|
| Owner: | changed from to |
| Resolution: | → Fixed |
| Status: | new → closed |
Fixed by revision [5743] in version: 3.3.7.0

Contains a file which creates and abend situation (testbadfile.htm) and which does not create an abend (testgoodfile.htm)