diff options
author | Dan Gudmundsson <[email protected]> | 2017-10-23 12:09:53 +0200 |
---|---|---|
committer | Dan Gudmundsson <[email protected]> | 2017-10-23 12:09:53 +0200 |
commit | e7e17c75b38392f6722a00df45581b104e2829e2 (patch) | |
tree | 411a7ba15c37e8c6beebec9e614985923384c045 /lib/wx | |
parent | 83f2ad6af98df7d7e0b744fcc775a64af1be5f4c (diff) | |
parent | fcbace8f04c741652820d9f91c6de7b49c92c1d9 (diff) | |
download | otp-e7e17c75b38392f6722a00df45581b104e2829e2.tar.gz otp-e7e17c75b38392f6722a00df45581b104e2829e2.tar.bz2 otp-e7e17c75b38392f6722a00df45581b104e2829e2.zip |
Merge branch 'maint'
* maint:
fix win32 share filename join/split (#1604)
Correct io_vec handling
Diffstat (limited to 'lib/wx')
-rw-r--r-- | lib/wx/c_src/wxe_driver.c | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/lib/wx/c_src/wxe_driver.c b/lib/wx/c_src/wxe_driver.c index 5da71818e5..26ae3564e7 100644 --- a/lib/wx/c_src/wxe_driver.c +++ b/lib/wx/c_src/wxe_driver.c @@ -33,6 +33,7 @@ #include <sys/types.h> #include <fcntl.h> +#include <assert.h> #include "wxe_driver.h" #define TEMP_BINARY_SIZE 512 @@ -234,13 +235,21 @@ standard_outputv(ErlDrvData drv_data, ErlIOVec* ev) sd->max_bins = max; } - if(ev->vsize == 2) { - binref->base = ev->iov[1].iov_base; - binref->size = ev->iov[1].iov_len; - binref->from = driver_caller(sd->port_handle); - bin = ev->binv[1]; - driver_binary_inc_refc(bin); /* Otherwise it could get deallocated */ - binref->bin = bin; + if(ev->size > 0) { + assert(ev->vsize == 2 && ev->iov[0].iov_len == 0 + && "erts changed how the ErlIOVec is structured for outputv"); + binref->from = driver_caller(sd->port_handle); + binref->size = ev->iov[1].iov_len; + if(ev->binv[1]) { + binref->base = ev->iov[1].iov_base; + bin = ev->binv[1]; + driver_binary_inc_refc(bin); /* Otherwise it could get deallocated */ + } else { + bin = driver_alloc_binary(ev->iov[1].iov_len); + memcpy(bin->orig_bytes, ev->iov[1].iov_base, ev->iov[1].iov_len); + binref->base = bin->orig_bytes; + } + binref->bin = bin; } else { /* Empty binary (becomes NULL) */ binref->base = NULL; binref->size = 0; |