You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It happens not often, but sometimes my app crashes on calling fz_run_page with System.AccessViolationException.
I cannot re-produce it, it happens occasionally on my client installations.
I guess the crashes are caused by the pinned but immediately un-pinned memory:
public PdfFileStream(IPdfSource source)
{
if (source is FileSource)
{
var fs = (FileSource)source;
Context = NativeMethods.NewContext(IntPtr.Zero, IntPtr.Zero, FZ_STORE_DEFAULT); // Creates the context
Stream = NativeMethods.OpenFile(Context, fs.Filename); // opens file as a stream
Document = NativeMethods.OpenDocumentStream(Context, ".pdf", Stream); // opens the document
}
else if (source is MemorySource)
{
var ms = (MemorySource)source;
Context = NativeMethods.NewContext(IntPtr.Zero, IntPtr.Zero, FZ_STORE_DEFAULT); // Creates the context
GCHandle pinnedArray = GCHandle.Alloc(ms.Bytes, GCHandleType.Pinned);
IntPtr pointer = pinnedArray.AddrOfPinnedObject();
Stream = NativeMethods.OpenStream(Context, pointer, ms.Bytes.Length); // opens file as a stream
Document = NativeMethods.OpenDocumentStream(Context, ".pdf", Stream); // opens the document
pinnedArray.Free();
}
}
I think pinnedArray must be an instance variable, and pinnedArray.Free() called in Dispose(), so the memory cannot get moved around by the garbage collector.
The text was updated successfully, but these errors were encountered:
It happens not often, but sometimes my app crashes on calling fz_run_page with System.AccessViolationException.
I cannot re-produce it, it happens occasionally on my client installations.
I guess the crashes are caused by the pinned but immediately un-pinned memory:
I think pinnedArray must be an instance variable, and pinnedArray.Free() called in Dispose(), so the memory cannot get moved around by the garbage collector.
The text was updated successfully, but these errors were encountered: