summaryrefslogtreecommitdiff
path: root/pjlib-util/src/pjstun-srv-test/usage.c
diff options
context:
space:
mode:
Diffstat (limited to 'pjlib-util/src/pjstun-srv-test/usage.c')
-rw-r--r--pjlib-util/src/pjstun-srv-test/usage.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/pjlib-util/src/pjstun-srv-test/usage.c b/pjlib-util/src/pjstun-srv-test/usage.c
index 198e0313..a8a5c274 100644
--- a/pjlib-util/src/pjstun-srv-test/usage.c
+++ b/pjlib-util/src/pjstun-srv-test/usage.c
@@ -82,8 +82,6 @@ PJ_DEF(pj_status_t) pj_stun_usage_create( pj_stun_server *srv,
if (status != PJ_SUCCESS)
goto on_error;
- pj_memcpy(&usage->cb, cb, sizeof(*cb));
-
usage->type = type;
status = pj_sock_socket(family, type, protocol, &usage->sock);
if (status != PJ_SUCCESS)
@@ -133,6 +131,12 @@ PJ_DEF(pj_status_t) pj_stun_usage_create( pj_stun_server *srv,
pj_stun_server_register_usage(srv, usage);
+ /* Only after everything has been initialized we copy the callback,
+ * to prevent callback from being called when we encounter error
+ * during initialiation (decendant would not expect this).
+ */
+ pj_memcpy(&usage->cb, cb, sizeof(*cb));
+
*p_usage = usage;
return PJ_SUCCESS;