Fix: remove the leak protection entirely
This commit is contained in:
@@ -163,14 +163,15 @@ extern "C" ANSOCR_API int CreateANSOCRHandleEx(ANSCENTER::ANSOCRBase** Handle,
|
||||
OutputDebugStringA(buf);
|
||||
}
|
||||
|
||||
// Release existing handle if called twice (prevents leak from LabVIEW)
|
||||
if (*Handle) {
|
||||
if (UnregisterOCRHandle(*Handle)) {
|
||||
(*Handle)->Destroy();
|
||||
delete *Handle;
|
||||
}
|
||||
*Handle = nullptr;
|
||||
}
|
||||
// Pure constructor: ignore *Handle(in). LabVIEW's CLF Node marshalling
|
||||
// reuses the same temp buffer per call site, so *Handle(in) often holds
|
||||
// leftover bytes from the previous Create's output even when the actual
|
||||
// LabVIEW wire is a different, freshly-allocated instance. Inspecting
|
||||
// *Handle(in) and destroying what we "see" tears down legitimate
|
||||
// parallel instances. (Same reasoning as CreateANSAWSHandle.)
|
||||
// Trade-off: a true double-Create on the same wire leaks the prior
|
||||
// handle -- caller's bug; the alternative is far worse.
|
||||
*Handle = nullptr;
|
||||
|
||||
// Validate limitSideLen: must be in (0, 20000], default to 960
|
||||
if (limitSideLen <= 0 || limitSideLen > 20000)
|
||||
|
||||
Reference in New Issue
Block a user