Skip to content

Instantly share code, notes, and snippets.

@stephank
Forked from pagameba/gist:710009
Created November 22, 2010 14:23
Show Gist options
  • Save stephank/710033 to your computer and use it in GitHub Desktop.
Save stephank/710033 to your computer and use it in GitHub Desktop.
static int EIO_AfterDrawMap(eio_req *req) {
HandleScope scope;
drawmap_request *drawmap_req =(drawmap_request *)req->data;
ev_unref(EV_DEFAULT_UC);
drawmap_req->map->Unref();
Local<Value> argv[2];
if (drawmap_req->data != NULL) {
Buffer * buffer = Buffer::New(drawmap_req->data, drawmap_req->size, FreeImageBuffer, NULL);
argv[0] = Local<Value>::New(Null());
argv[1] = Local<Value>::New(buffer->handle_));
} else {
errorObj * err = msGetErrorObj();
Local<Value> _arg_ = External::New(err);
argv[0] = Local<Value>::New(ErrorObj::constructor_template->GetFunction()->NewInstance(1, &_arg_));
argv[1] = Local<Value>::New(Null());
}
TryCatch try_catch;
drawmap_req->cb->Call(Context::GetCurrent()->Global(), 2, argv);
if (try_catch.HasCaught()) {
FatalException(try_catch);
}
drawmap_req->cb.Dispose();
delete drawmap_req;
return 0;
}
@pagameba
Copy link

moved TryCatch to before if, removed extraneous ) on line 12, get this in error case:

node(17393,0x7fff70132ca0) malloc: *** error for object 0x202020202020307: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
Abort trap

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment