Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return value of mosquitto_new is not checked in mosquittopp::mosquittopp() #113

Closed
ralight opened this issue Mar 15, 2016 · 1 comment
Closed

Comments

@ralight
Copy link
Contributor

ralight commented Mar 15, 2016

migrated from Bugzilla #473105
status UNCONFIRMED severity normal in component Mosquitto client library for 1.4
Reported in version 1.3.x on platform All
Assigned to: Roger Light

On 2015-07-20 14:24:18 -0400, Trygve Laugstøl wrote:

The v1.3 and v1.4 constructor both look like this:

m_mosq = mosquitto_new(id, clean_session, this);
mosquitto_connect_callback_set(m_mosq, on_connect_wrapper);

If the user does something dumb (like passing in NULL and false for id and clean_session) mosquitto_new will return NULL and set errno to EINVAL. The next call will then execute pthread_mutex_lock(&mosq->callback_mutex); but mosq will be NULL.

I'm not sure what the best way to handle the problem is. Options include throwing an exception, just drop setting the callbacks and have the sub-class/user check errno or have a static method that returns the instance. The last option makes it harder to follow the current pattern of extending mosquittopp.

@elfring
Copy link

elfring commented Mar 18, 2016

Is such a bug report similar to the issue "Completion of error handling"?

@ralight ralight closed this as completed Sep 25, 2018
@lock lock bot locked as resolved and limited conversation to collaborators Aug 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants