diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2017-05-18 20:48:15 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2017-05-18 20:48:15 -0700 |
commit | 30061be2a8e1fae63513aa2732d16ed26283e595 (patch) | |
tree | 455754dbcec428b646a10a39b87e85c428068033 | |
parent | 8d18fe8b9f0eb8052777931ef5fdf3e401254b87 (diff) | |
download | txr-30061be2a8e1fae63513aa2732d16ed26283e595.tar.gz txr-30061be2a8e1fae63513aa2732d16ed26283e595.tar.bz2 txr-30061be2a8e1fae63513aa2732d16ed26283e595.zip |
ffi: bugfix: obj could be nil in buf ops.
* ffi.c (ffi_buf_in): Only get the original pointer if obj
isn't nil; otherwise use a null pointer.
(ffi_buf_d_in): Don't refer to length_buf(obj); obj could
be nil. And anyway, we know the buffer size from the type.
-rw-r--r-- | ffi.c | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -703,7 +703,7 @@ static val ffi_buf_in(struct txr_ffi_type *tft, int copy, mem_t *src, val obj, val self) { mem_t **loc = coerce(mem_t **, src); - mem_t *origptr = buf_get(obj, self); + mem_t *origptr = if3(obj, buf_get(obj, self), 0); if (copy && *loc != origptr) obj = if2(*loc, make_duplicate_buf(length_buf(obj), *loc)); @@ -734,7 +734,7 @@ static val ffi_buf_d_in(struct txr_ffi_type *tft, int copy, mem_t *src, mem_t **loc = coerce(mem_t **, src); if (copy) { - obj = if2(*loc, make_borrowed_buf(length_buf(obj), *loc)); + obj = if2(*loc, make_borrowed_buf(num(tft->nelem), *loc)); *loc = 0; } |