Skip to content

Commit

Permalink
fix issue #7 coercing a non CHARSXP causes backend crash (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
davecramer committed Jun 30, 2016
1 parent 86ec0a7 commit 42ed3da
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions pg_conversion.c
Original file line number Diff line number Diff line change
Expand Up @@ -1003,7 +1003,7 @@ get_scalar_datum(SEXP rval, Oid result_typid, FmgrInfo result_in_func, bool *isn
{
Datum dvalue;
SEXP obj;
const char *value;
const char *value=NULL;

/*
* Element type is zero, we don't have an array, so coerce to string
Expand All @@ -1027,7 +1027,18 @@ get_scalar_datum(SEXP rval, Oid result_typid, FmgrInfo result_in_func, bool *isn
dvalue = (Datum) 0;
return dvalue;
}
value = CHAR(STRING_ELT(obj, 0));
obj = STRING_ELT(obj, 0);
if (TYPEOF(obj) == CHARSXP )
{
value = CHAR(obj);
}
else
{
ereport(ERROR,
(errcode(ERRCODE_DATA_EXCEPTION),
errmsg("R interpreter expression evaluation error"),
errdetail("return type cannot be coerced to char")));
}
UNPROTECT(1);

if (value != NULL)
Expand Down

0 comments on commit 42ed3da

Please sign in to comment.