0
0
mirror of https://github.com/zeromq/libzmq.git synced 2024-12-27 15:41:05 +08:00

Merge pull request #4038 from bluca/api_breakage

Problem: zmq_ctx_get API broken
This commit is contained in:
Doron Somech 2020-09-11 09:54:50 +03:00 committed by GitHub
commit e915449184
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 7 deletions

View File

@ -195,14 +195,11 @@ int zmq_ctx_set_ext (void *ctx_,
int zmq_ctx_get (void *ctx_, int option_)
{
int optval = 0;
size_t optvallen = sizeof (int);
if (zmq_ctx_get_ext (ctx_, option_, &optval, &optvallen) == 0) {
return optval;
if (!ctx_ || !(static_cast<zmq::ctx_t *> (ctx_))->check_tag ()) {
errno = EFAULT;
return -1;
}
errno = EFAULT;
return -1;
return (static_cast<zmq::ctx_t *> (ctx_))->get (option_);
}
int zmq_ctx_get_ext (void *ctx_, int option_, void *optval_, size_t *optvallen_)

View File

@ -283,6 +283,14 @@ void test_ctx_option_blocky ()
test_context_socket_close (router);
}
void test_ctx_option_invalid ()
{
TEST_ASSERT_EQUAL_INT (-1, zmq_ctx_set (get_test_context (), -1, 0));
TEST_ASSERT_EQUAL_INT (EINVAL, errno);
TEST_ASSERT_EQUAL_INT (-1, zmq_ctx_get (get_test_context (), -1));
TEST_ASSERT_EQUAL_INT (EINVAL, errno);
}
int main (void)
{
setup_test_environment ();
@ -297,5 +305,6 @@ int main (void)
RUN_TEST (test_ctx_thread_opts);
RUN_TEST (test_ctx_zero_copy);
RUN_TEST (test_ctx_option_blocky);
RUN_TEST (test_ctx_option_invalid);
return UNITY_END ();
}