Skip to content

Commit

Permalink
pj_dns_srv_resolve() returns query object when it shouldn't (#3990)
Browse files Browse the repository at this point in the history
  • Loading branch information
andreas-wehrmann committed Jun 19, 2024
1 parent cd89bb6 commit 9cca8e6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pjlib-util/include/pjlib-util/resolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ PJ_DECL(pj_status_t) pj_dns_resolver_destroy(pj_dns_resolver *resolver,
* @param user_data Arbitrary user data to be associated with the query,
* and which will be given back in the callback.
* @param p_query Optional pointer to receive the query object, if one
* was started. If this pointer is specified, a NULL may
* was started. If this pointer is specified, a NULL will
* be returned if response cache is available immediately.
*
* @return PJ_SUCCESS if either an asynchronous query has been
Expand Down
2 changes: 1 addition & 1 deletion pjlib-util/include/pjlib-util/srv_resolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ typedef void pj_dns_srv_resolver_cb(void *user_data,
* @param cb Pointer to callback function to receive the
* notification when the resolution process completes.
* @param p_query Optional pointer to receive the query object, if one
* was started. If this pointer is specified, a NULL may
* was started. If this pointer is specified, a NULL will
* be returned if response cache is available immediately.
*
* @return PJ_SUCCESS on success, or the appropriate error code.
Expand Down
7 changes: 5 additions & 2 deletions pjlib-util/src/pjlib-util/srv_resolver.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ PJ_DEF(pj_status_t) pj_dns_srv_resolve( const pj_str_t *domain_name,
{
pj_size_t len;
pj_str_t target_name;
pj_dns_srv_async_query *query_job;
pj_dns_srv_async_query *query_job, *p_q = NULL;
pj_status_t status;

PJ_ASSERT_RETURN(domain_name && domain_name->slen &&
Expand Down Expand Up @@ -156,8 +156,11 @@ PJ_DEF(pj_status_t) pj_dns_srv_resolve( const pj_str_t *domain_name,
query_job->dns_state, 0,
&dns_callback,
query_job, &query_job->q_srv);
if (query_job->q_srv)
p_q = query_job;

if (status==PJ_SUCCESS && p_query)
*p_query = query_job;
*p_query = p_q;

return status;
}
Expand Down

0 comments on commit 9cca8e6

Please sign in to comment.