mirror of
https://github.com/zeromq/libzmq.git
synced 2024-12-27 15:41:05 +08:00
Problem: get_monitor_event_internal segfaults when using address
Solution: dereference the pointer to the array before accessing the element
This commit is contained in:
parent
b18d28eec1
commit
f884fa725c
@ -71,7 +71,7 @@ static int get_monitor_event_internal (void *monitor_,
|
||||
size_t size = zmq_msg_size (&msg);
|
||||
*address_ = (char *) malloc (size + 1);
|
||||
memcpy (*address_, data, size);
|
||||
*address_[size] = 0;
|
||||
(*address_)[size] = 0;
|
||||
}
|
||||
return event;
|
||||
}
|
||||
@ -236,7 +236,7 @@ static int64_t get_monitor_event_internal_v2 (void *monitor_,
|
||||
size_t size = zmq_msg_size (&msg);
|
||||
*local_address_ = (char *) malloc (size + 1);
|
||||
memcpy (*local_address_, data, size);
|
||||
*local_address_[size] = 0;
|
||||
(*local_address_)[size] = 0;
|
||||
}
|
||||
|
||||
// Fourth and last frame in message contains remote address
|
||||
@ -250,7 +250,7 @@ static int64_t get_monitor_event_internal_v2 (void *monitor_,
|
||||
size_t size = zmq_msg_size (&msg);
|
||||
*remote_address_ = (char *) malloc (size + 1);
|
||||
memcpy (*remote_address_, data, size);
|
||||
*remote_address_[size] = 0;
|
||||
(*remote_address_)[size] = 0;
|
||||
}
|
||||
return event;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user