Skip to content

Memory corruption bug in query mangling of empty strings #23

Description

@boothby

Using cl-sqlite-20190813-git in sbcl, I've hit an issue where empty strings are replaced with garbage characters. In the example below, the empty string is replaced with ":" upon insertion.

>>> (let ((db (connect ":memory:")))
(execute-non-query db "create table foo (bar text)")
(execute-non-query db "insert into foo (bar) values (?)" "")
(execute-to-list db "select * from foo")
)
((":"))

If I write the value into the query; it works fine:

>>> (let ((db (connect ":memory:")))
(execute-non-query db "create table foo (bar text)")
(execute-non-query db "insert into foo (bar) values (\"\")")
(execute-to-list db "select * from foo")
)
((""))

A colleague of mine has traced the issue to line 388 of sqlite.lisp; the problem goes away with the length -1 is replaced by (length value) but you may prefer a different fix.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions