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 On Listing too many items #3

Closed
underhood opened this issue Jan 27, 2017 · 2 comments
Closed

Crash On Listing too many items #3

underhood opened this issue Jan 27, 2017 · 2 comments

Comments

@underhood
Copy link

underhood commented Jan 27, 2017

In
void COPCServer::getItemNames(std::vectorstd::string & opcItemNames)

cycle:
while((result = iEnum->Next(1, &str, &strSize)) == S_OK)
{
WCHAR * fullName;
result = iOpcNamespace->GetItemID(str, &fullName);
if (SUCCEEDED(result)){
USES_CONVERSION;
char * cStr = OLE2T(fullName);
//char * cStr = OLE2T(str);
//printf("Adding %s\n", cStr);
opcItemNames.push_back(cStr);
COPCClient::comFree(fullName);
}
COPCClient::comFree(str);
}

char * cStr = OLE2T(fullName); allocates memory on stack where it is not freed until we exit function. Since it is called in While loop it will cause stack overflow and crash if there is too many items to list,

My workaround was to create wrapper function around OLE2T which moves data to heap.

@edimetia3d
Copy link
Owner

I have not tested it yet , since MSDN says it should work.

Thanks for reporting.

@underhood
Copy link
Author

underhood commented Feb 7, 2017 via email

edimetia3d added a commit that referenced this issue Apr 13, 2017
Fix: a string conversion error

fix #3
edimetia3d added a commit that referenced this issue Apr 13, 2017
Fix: a string conversion error

fix #3
edimetia3d added a commit that referenced this issue Apr 13, 2017
Fix: a string conversion error

fix #3
gc87 added a commit to gc87/OPC-Client-X64 that referenced this issue Aug 4, 2022
feat: group operation, item operation
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