-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
different form fill info allocation to fix mem read issues
- Loading branch information
Showing
8 changed files
with
118 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
using System; | ||
using System.Runtime.InteropServices; | ||
|
||
namespace Docnet.Core.Bindings | ||
{ | ||
internal sealed class FormWrapper : IDisposable | ||
{ | ||
private readonly IntPtr _ptr; | ||
|
||
public FormWrapper(DocumentWrapper docWrapper) | ||
{ | ||
var formInfo = new FPDF_FORMFILLINFO(); | ||
|
||
_ptr = Marshal.AllocHGlobal(Marshal.SizeOf(formInfo)); | ||
|
||
for (var i = 1; i <= 2; i++) | ||
{ | ||
formInfo.version = i; | ||
|
||
Marshal.StructureToPtr(formInfo, _ptr, false); | ||
|
||
Instance = fpdf_view.FPDFDOCInitFormFillEnvironment(docWrapper.Instance, _ptr); | ||
|
||
if (Instance != null) | ||
{ | ||
break; | ||
} | ||
} | ||
} | ||
|
||
public FpdfFormHandleT Instance { get; private set; } | ||
|
||
public void Dispose() | ||
{ | ||
if (Instance != null) | ||
{ | ||
fpdf_view.FPDF_ExitFormFillEnvironment(Instance); | ||
} | ||
|
||
Marshal.FreeHGlobal(_ptr); | ||
|
||
Instance = null; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters