Skip to content

Commit

Permalink
Wrap BLOB function parameters in SQLite3::Blob if encoding is not ava…
Browse files Browse the repository at this point in the history
…ilable.
  • Loading branch information
Jim Flood committed Dec 5, 2015
1 parent deecab9 commit 220c194
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions ext/sqlite3/database.c
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,14 @@ static VALUE sqlite3val2rb(sqlite3_value * val)
which is what we want, as blobs are binary
*/
int len = sqlite3_value_bytes(val);
#ifdef HAVE_RUBY_ENCODING_H
return rb_tainted_str_new((const char *)sqlite3_value_blob(val), len);
#else
/* When encoding is not available, make it class SQLite3::Blob. */
VALUE strargv[1];
strargv[0] = rb_tainted_str_new((const char *)sqlite3_value_blob(val), len);
return rb_class_new_instance(1, strargv, cSqlite3Blob);
#endif
break;
}
case SQLITE_NULL:
Expand Down

0 comments on commit 220c194

Please sign in to comment.