Skip to content

Commit 88d6cfd

Browse files
committed
Blob I/O: early return
1 parent 6188ff5 commit 88d6cfd

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

blob_io.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,16 @@ func (conn *SQLiteConn) Blob(database, table, column string, rowid int64, flags
4545
var blob *C.sqlite3_blob
4646
ret := C.sqlite3_blob_open(conn.db, databaseptr, tableptr, columnptr, C.longlong(rowid), C.int(flags), &blob)
4747

48-
if ret == C.SQLITE_OK {
49-
size := int(C.sqlite3_blob_bytes(blob))
50-
bb := &SQLiteBlob{conn, blob, size, 0}
48+
if ret != C.SQLITE_OK {
49+
return nil, conn.lastError()
50+
}
5151

52-
runtime.SetFinalizer(bb, (*SQLiteBlob).Close)
52+
size := int(C.sqlite3_blob_bytes(blob))
53+
bb := &SQLiteBlob{conn, blob, size, 0}
5354

54-
return bb, nil
55-
}
55+
runtime.SetFinalizer(bb, (*SQLiteBlob).Close)
5656

57-
return nil, conn.lastError()
57+
return bb, nil
5858
}
5959

6060
// Read implements the io.Reader interface.

0 commit comments

Comments
 (0)