瀏覽代碼

prevent client's method call from segfault when method call not implemented

Stasik0 9 年之前
父節點
當前提交
e2e0523916
共有 1 個文件被更改,包括 9 次插入7 次删除
  1. 9 7
      src/client/ua_client.c

+ 9 - 7
src/client/ua_client.c

@@ -1048,13 +1048,15 @@ UA_StatusCode UA_Client_CallServerMethod(UA_Client *client, UA_NodeId objectNode
     rq->inputArgumentsSize = -1;
     UA_CallRequest_deleteMembers(&request);
     UA_StatusCode retval = response.responseHeader.serviceResult;
-    retval |= response.results[0].statusCode;
-
-    if(retval == UA_STATUSCODE_GOOD) {
-        *output = response.results[0].outputArguments;
-        *outputSize = response.results[0].outputArgumentsSize;
-        response.results[0].outputArguments = UA_NULL;
-        response.results[0].outputArgumentsSize = -1;
+    if(response.resultsSize > 0){
+        retval |= response.results[0].statusCode;
+
+        if(retval == UA_STATUSCODE_GOOD) {
+            *output = response.results[0].outputArguments;
+            *outputSize = response.results[0].outputArgumentsSize;
+            response.results[0].outputArguments = UA_NULL;
+            response.results[0].outputArgumentsSize = -1;
+        }
     }
     UA_CallResponse_deleteMembers(&response);
     return retval;