Avoid crash if form is nil when filling

This commit is contained in:
Gunnsteinn Hall 2018-10-03 14:56:23 +00:00
parent b39c7065e8
commit ab87949919
2 changed files with 8 additions and 0 deletions

View File

@ -246,6 +246,9 @@ type FieldValueProvider interface {
// Fill populates `form` with values provided by `provider`.
func (form *PdfAcroForm) Fill(provider FieldValueProvider) error {
if form == nil {
return nil
}
objMap, err := provider.FieldValues()
if err != nil {
return err

View File

@ -155,3 +155,8 @@ endobj
t.Fatalf("Mismatch in expected and actual field dictionaries (deep)")
}
}
func TestFormNil(t *testing.T) {
var form *PdfAcroForm
form.Fill(nil)
}