Skip to content

Commit

Permalink
add additional input checking
Browse files Browse the repository at this point in the history
  • Loading branch information
Charles Banning committed Jun 6, 2017
1 parent a954c14 commit 6ff1cd3
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pseudo.go
Original file line number Diff line number Diff line change
Expand Up @@ -832,6 +832,7 @@ func (s *Session) readDimacsFile(r io.Reader) error {
buf := bufio.NewReader(r)
var atEOF bool
var n uint64
var haveSource, haveSink bool
for {
if atEOF {
break
Expand Down Expand Up @@ -953,9 +954,17 @@ func (s *Session) readDimacsFile(r io.Reader) error {
ch1 = vals[2]

if ch1 == "s" {
if haveSource {
return fmt.Errorf("muliple 's' n lines")
}
s.source = i
haveSource = true
} else if ch1 == "t" {
if haveSink {
return fmt.Errorf("multiple 't' n lines")
}
s.sink = i
haveSink = true
} else {
return fmt.Errorf("unrecognized character %s on line %d", ch1, numLines)
}
Expand Down

0 comments on commit 6ff1cd3

Please sign in to comment.