diff options
| author | 2021-12-26 18:04:59 +0100 | |
|---|---|---|
| committer | 2021-12-26 18:20:16 +0100 | |
| commit | c3906473fdf90eb0953f8d0ea9c0a1f87e44e98b (patch) | |
| tree | d5c0702460cbec89cdc91b804ec72c13314c9d8d /sqlite.zig | |
| parent | add tests for crashes found by fuzzing (diff) | |
| download | zig-sqlite-c3906473fdf90eb0953f8d0ea9c0a1f87e44e98b.tar.gz zig-sqlite-c3906473fdf90eb0953f8d0ea9c0a1f87e44e98b.tar.xz zig-sqlite-c3906473fdf90eb0953f8d0ea9c0a1f87e44e98b.zip | |
fix a panic in Statement.prepare if the query is empty
sqlite3_prepare_v2 doesn't return an error code if the input query
string is empty or is a comment, instead the statement will be null.
Diffstat (limited to 'sqlite.zig')
| -rw-r--r-- | sqlite.zig | 7 |
1 files changed, 7 insertions, 0 deletions
| @@ -1249,6 +1249,13 @@ pub const DynamicStatement = struct { | |||
| 1249 | diags.err = getLastDetailedErrorFromDb(db.db); | 1249 | diags.err = getLastDetailedErrorFromDb(db.db); |
| 1250 | return errors.errorFromResultCode(result); | 1250 | return errors.errorFromResultCode(result); |
| 1251 | } | 1251 | } |
| 1252 | if (tmp == null) { | ||
| 1253 | diags.err = .{ | ||
| 1254 | .code = 0, | ||
| 1255 | .message = "the input query is not valid SQL (empty string or a comment)", | ||
| 1256 | }; | ||
| 1257 | return error.SQLiteError; | ||
| 1258 | } | ||
| 1252 | break :blk tmp.?; | 1259 | break :blk tmp.?; |
| 1253 | }; | 1260 | }; |
| 1254 | return Self{ | 1261 | return Self{ |