Skip to content

Commit e33ed5e

Browse files
John Haleytbranyen
authored andcommitted
Credentials are passing but getting seg faults
1 parent bef8796 commit e33ed5e

4 files changed

Lines changed: 15 additions & 14 deletions

File tree

generate/descriptor.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{
1+
{
22
"attr": {
33
"cType": null,
44

@@ -286,8 +286,9 @@
286286
"functions": {
287287
"git_cred_ssh_key_from_agent": {
288288
"ignore": false,
289-
"isPrototypeMethod": true,
290-
"args": [{ "isSelf": true }]
289+
"isPrototypeMethod": false,
290+
"args": [{ "isSelf": false }],
291+
"isAsync": false
291292
}
292293
}
293294
},

generate/partials/field_accessors.cc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ NAN_SETTER({{ cppClassName }}::Set{{ field.cppFunctionName }}) {
6666

6767
{%each field.args|argsInfo as arg %}
6868
baton->{{ arg.name }} = {{ arg.name }};
69-
7069
{%endeach%}
7170
baton->req.data = baton;
7271
baton->done = false;
@@ -78,7 +77,7 @@ NAN_SETTER({{ cppClassName }}::Set{{ field.cppFunctionName }}) {
7877
}
7978

8079
{%each field|returnsInfo true false as _return %}
81-
{{ _return.name }} = baton->{{ _return.name }};
80+
*{{ _return.name }} = *baton->{{ _return.name }};
8281
{%endeach%}
8382

8483
return baton->result;
@@ -116,20 +115,21 @@ void {{ cppClassName }}::{{ field.name }}_asyncAfter(uv_work_t* req, int status)
116115
{%endeach%}
117116
};
118117

118+
TryCatch tryCatch;
119119
Local<Value> result = Local<Value>::New(Function::Cast(*instance->{{ field.name }})->Call(Context::GetCurrent()->Global(), {{ field.args|jsArgsCount }}, argv));
120120
{{ field.returnType }} resultStatus;
121121

122122
{%each field|returnsInfo true false as _return%}
123-
if (!result->IsNull() && !result->IsUndefined()) {
123+
if (result.IsEmpty() || result->IsNativeError()) {
124+
baton->result = {{ field.returnError }};
125+
}
126+
else if (!result->IsNull() && !result->IsUndefined()) {
124127
{{ _return.cppClassName }}* wrapper = ObjectWrap::Unwrap<{{ _return.cppClassName }}>(result->ToObject());
125128
wrapper->selfFreeing = false;
126129

127130
baton->{{ _return.name }} = wrapper->GetRefValue();
128131
baton->result = {{ field.returnSuccess }};
129132
}
130-
else if (result->IsNativeError()) {
131-
baton->result = {{ field.returnError }};
132-
}
133133
else {
134134
baton->result = {{ field.returnNoResults }};
135135
}

generate/setup.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,9 @@ fileNames.forEach(function(fileName, index) {
298298
descriptor.isConstructorMethod = isCtor;
299299

300300
// Set the prototype method argument.
301-
descriptor.isPrototypeMethod = !descriptor.isConstructorMethod;
301+
if (functionDescriptor.isPrototypeMethod !== false) {
302+
descriptor.isPrototypeMethod = !descriptor.isConstructorMethod;
303+
}
302304

303305
var hasReturn = false;
304306

test/tests/clone.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,8 @@ describe("Clone", function() {
4848
var opts = {
4949
ignoreCertErrors: 1,
5050
remoteCallbacks: {
51-
credentials: function() {
52-
var cred = new NodeGit.GitCred();
53-
cred.keyFromSshAgent("git");
54-
return cred;
51+
credentials: function(url, userName) {
52+
return NodeGit.Cred.sshKeyFromAgent(userName);
5553
}
5654
}
5755
};

0 commit comments

Comments
 (0)