Skip to content

Commit

Permalink
Fixed buffer mis-allocation and added Linux imports of DS-functions
Browse files Browse the repository at this point in the history
Signed-off-by: John Medland <[email protected]>
  • Loading branch information
j-medland committed Sep 23, 2024
1 parent dc6bf10 commit 82217d6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 16 deletions.
13 changes: 6 additions & 7 deletions src/grpc_interop.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,15 @@ namespace grpc_labview
//---------------------------------------------------------------------
void OccurServerEvent(LVUserEventRef event, gRPCid* data, std::string eventMethodName)
{
LStr* lvMethodName = (LStr*)malloc(sizeof(int32_t) + eventMethodName.length() + 1);
lvMethodName->cnt = eventMethodName.length();
memcpy(lvMethodName->str, eventMethodName.c_str(), eventMethodName.length());

GeneralMethodEventData eventData;
eventData.methodData = data;
eventData.methodName = &lvMethodName;
eventData.methodName = nullptr;

SetLVString(&eventData.methodName, eventMethodName);

auto error = PostUserEvent(event, &eventData);

free(lvMethodName);
DSDisposeHandle(eventData.methodName);
}

//---------------------------------------------------------------------
Expand Down Expand Up @@ -479,4 +478,4 @@ LIBRARY_EXPORT int32_t SetLVRTModulePath(const char* modulePath)
grpc_labview::SetLVRTModulePath(modulePath);

return 0;
}
}
13 changes: 4 additions & 9 deletions src/lv_interop.cc
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,9 @@ namespace grpc_labview
PostLVUserEvent = (PostLVUserEvent_T)dlsym(RTLD_DEFAULT, "PostLVUserEvent");
Occur = (Occur_T)dlsym(RTLD_DEFAULT, "Occur");
RTSetCleanupProc = (RTSetCleanupProc_T)dlsym(RTLD_DEFAULT, "RTSetCleanupProc");

if (NumericArrayResizeImp == nullptr ||
PostLVUserEvent == nullptr ||
Occur == nullptr ||
RTSetCleanupProc == nullptr)
{
exit(grpc::StatusCode::INTERNAL);
}
DSNewHandleImpl = (DSNewHandlePtr_T)dlsym(RTLD_DEFAULT, "DSNewHandle");
DSSetHandleSizeImpl = (DSSetHandleSize_T)dlsym(RTLD_DEFAULT, "DSSetHandleSize");
DSDisposeHandleImpl = (DSDisposeHandle_T)dlsym(RTLD_DEFAULT, "DSDisposeHandle");
}

#endif
Expand Down Expand Up @@ -216,4 +211,4 @@ namespace grpc_labview
return clusterOffset;
#endif
}
}
}

0 comments on commit 82217d6

Please sign in to comment.