From ed00acdb054d3e26b9a2ffdb09fdd94585bab65d Mon Sep 17 00:00:00 2001 From: Dan Meyers Date: Sat, 10 Jun 2017 13:54:41 -0400 Subject: prevent panic when registering barcode fails (#118) --- contrib/barcode/barcode.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'contrib/barcode/barcode.go') diff --git a/contrib/barcode/barcode.go b/contrib/barcode/barcode.go index 63a4908..9f8d3ff 100644 --- a/contrib/barcode/barcode.go +++ b/contrib/barcode/barcode.go @@ -20,6 +20,11 @@ package barcode import ( "bytes" "errors" + "image/jpeg" + "io" + "strconv" + "sync" + "github.com/boombuler/barcode" "github.com/boombuler/barcode/aztec" "github.com/boombuler/barcode/codabar" @@ -31,10 +36,6 @@ import ( "github.com/boombuler/barcode/twooffive" "github.com/jung-kurt/gofpdf" "github.com/ruudk/golang-pdf417" - "image/jpeg" - "io" - "strconv" - "sync" ) // barcodes represents the barcodes that have been registered through this @@ -197,6 +198,7 @@ func RegisterTwoOfFive(pdf barcodePdf, code string, interleaved bool) string { func registerBarcode(pdf barcodePdf, bcode barcode.Barcode, err error) string { if err != nil { pdf.SetError(err) + return "" } return Register(bcode) -- cgit v1.2.1-24-ge1ad