From 6dc7d618873edb82ab5a561b15b077a1f33ad5b1 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Thu, 15 Sep 2016 10:59:12 +0200 Subject: [PATCH] Better handling of setsockopt --- f77_zmq.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/f77_zmq.c b/f77_zmq.c index a371159..c276b92 100644 --- a/f77_zmq.c +++ b/f77_zmq.c @@ -207,7 +207,12 @@ int f77_zmq_disconnect_ (void* *socket, char* address_in, int address_len) int f77_zmq_setsockopt_ (void* *socket, int* option_name, void* option_value, int* option_len, int dummy) { - return zmq_setsockopt (*socket, *option_name, option_value, *option_len); + int result; + void * value = malloc(*option_len); + memcpy(value, option_value, (size_t) *option_len); + result = zmq_setsockopt (*socket, *option_name, value, *option_len); + free(value); + return result; } int f77_zmq_getsockopt_ (void* *socket, int* option_name, void *option_value, int *option_len, int dummy)