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

Crash due to "Unknown Error" #32

Closed
celer opened this issue Jun 14, 2012 · 2 comments
Closed

Crash due to "Unknown Error" #32

celer opened this issue Jun 14, 2012 · 2 comments

Comments

@celer
Copy link

celer commented Jun 14, 2012

Hi, so we're seeing crash in the following function because serviceName, serviceType and replyDomain are NULL, which occurs when DNSServiceErrorType is -65537, aka "Uknown Error". We haven't figured out what is causing the unknown error, but regardless mdns shouldn't crash when this happens.

static
void
DNSSD_API
OnServiceChanged(DNSServiceRef sdRef, DNSServiceFlags flags, 
        uint32_t interfaceIndex, DNSServiceErrorType errorCode, 
        const char * serviceName, const char * serviceType,
        const char * replyDomain, void * context)
{
    HandleScope scope;
    ServiceRef * serviceRef = static_cast<ServiceRef*>(context);
    Handle<Function> callback = serviceRef->GetCallback();
    Handle<Object> this_ = serviceRef->GetThis();

    const size_t argc(8);
    Local<Value> args[argc];
    args[0] = Local<Object>::New(serviceRef->handle_);
    args[1] = Integer::New(flags);
    args[2] = Integer::New(interfaceIndex);
    args[3] = Integer::New(errorCode);
    args[4] = String::New(serviceName);
    args[5] = String::New(serviceType);
    args[6] = String::New(replyDomain);
    if (serviceRef->GetContext().IsEmpty()) {
        args[7] = Local<Value>::New(Undefined());
    } else {
        args[7] = Local<Value>::New(serviceRef->GetContext());
    }
    callback->Call(this_, argc, args);
}

Our fix is as so:

    if(serviceName)
      args[4] = String::New(serviceName);
    else
      args[4] = Local<Value>::New(Undefined());
    if(serviceType)
      args[5] = String::New(serviceType);
    else
      args[5] = Local<Value>::New(Undefined());
    if(replyDomain)
      args[6] = String::New(replyDomain);
    else
      args[6] = Local<Value>::New(Undefined());
@agnat
Copy link
Owner

agnat commented Jun 17, 2012

Thanks for the report. I'll do a release after fixing the other callbacks accordingly.

@agnat agnat closed this as completed in 0969712 Jun 17, 2012
@agnat
Copy link
Owner

agnat commented Jun 17, 2012

Bugfix released in v0.0.7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants