Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Null pointer when fetching an empty BLOB #561

Closed
brunokoga opened this issue Dec 13, 2016 · 1 comment
Closed

Null pointer when fetching an empty BLOB #561

brunokoga opened this issue Dec 13, 2016 · 1 comment

Comments

@brunokoga
Copy link

brunokoga commented Dec 13, 2016

According to the SQLite Documentation:

The return value from sqlite3_column_blob() for a zero-length BLOB is a NULL pointer

But this is the way SQLite.swift handles BLOB (on struct Cursor in Statements.swift):

  public subscript(idx: Int) -> Blob {
        if let pointer = sqlite3_column_blob(handle, Int32(idx)) {
            let length = Int(sqlite3_column_bytes(handle, Int32(idx)))
            return Blob(bytes: pointer, length: length)
        } else {
            fatalError("sqlite3_column_blob returned NULL")
        }
    }

Shouldn't the else return an empty BLOB (Blob(bytes: [])) in this case?

@jberkel
Copy link
Collaborator

jberkel commented Dec 13, 2016

Good catch, just pushed a fix for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants