-
Notifications
You must be signed in to change notification settings - Fork 74
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
Comments
I have not tested it yet , since MSDN says it should work. Thanks for reporting. |
Note the ATL3 vs. 7 comparison table:
The string is freed when the function is exited.
Not suitable for use in loops.Memory use grows until the function is exited.
Not good for large strings.Stack space is limited.
Usually require USES_CONVERSION to be defined.
This is exactly what i experienced crash inside the loop on stack overflow
inside the conversion macro which in debuger showed use of malloca (which
is allocate on stack)
…On Thu, Feb 2, 2017 at 4:09 PM, Wayne Paper ***@***.***> wrote:
I have not tested it yet , since MSDN
<https://msdn.microsoft.com/library/87zae4a3(v=vs.140).aspx> says it
should work.
Thanks for reporting.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#3 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AGXYv2ueMXNnRHgneg8f6oqV-a90QqUlks5rYfHAgaJpZM4LvsT_>
.
|
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
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.
The text was updated successfully, but these errors were encountered: