aboutsummaryrefslogtreecommitdiffstats
path: root/lib/wx
diff options
context:
space:
mode:
authorDan Gudmundsson <[email protected]>2017-10-17 10:28:51 +0200
committerDan Gudmundsson <[email protected]>2017-10-17 12:34:09 +0200
commit823cab1ec24af0235195b14ee66a8642e4913699 (patch)
treed94e89f470982479b8272fb68a07b8bee81a70d6 /lib/wx
parent02b4f09c161b27e44a2beef724d2edd6b00d4d29 (diff)
downloadotp-823cab1ec24af0235195b14ee66a8642e4913699.tar.gz
otp-823cab1ec24af0235195b14ee66a8642e4913699.tar.bz2
otp-823cab1ec24af0235195b14ee66a8642e4913699.zip
Correct io_vec handling
Can not depend on internal knowledge of binaries any more it changed and caused at least opengl to crash in OTP-20.1
Diffstat (limited to 'lib/wx')
-rw-r--r--lib/wx/c_src/wxe_driver.c23
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;