Skip to content

Commit

Permalink
cmd/gotext: fix segfault in extract & rewrite commands
Browse files Browse the repository at this point in the history
If extract or rewrite are called with no arguments it results in a
segmentation fault, since we dereference the out flag that was
not defined for these commands.

Fixes golang/go#62697

Change-Id: I697943b7c221431d0361bcec74c18183f6e141ea
GitHub-Last-Rev: 313ddfa
GitHub-Pull-Request: #46
Reviewed-on: https://go-review.googlesource.com/c/text/+/529255
Reviewed-by: Marcel van Lohuizen <[email protected]>
Auto-Submit: Ian Lance Taylor <[email protected]>
Reviewed-by: Ian Lance Taylor <[email protected]>
LUCI-TryBot-Result: Go LUCI <[email protected]>
Reviewed-by: Dmitri Shuralyov <[email protected]>
  • Loading branch information
mauri870 authored and gopherbot committed May 14, 2024
1 parent 59e1219 commit 9c2f3a2
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion cmd/gotext/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,18 @@ func config() (*pipeline.Config, error) {
if err != nil {
return nil, wrap(err, "invalid srclang")
}

// Use a default value since rewrite and extract don't have an out flag.
genFile := ""
if out != nil {
genFile = *out
}

return &pipeline.Config{
SourceLanguage: tag,
Supported: getLangs(),
TranslationsPattern: `messages\.(.*)\.json$`,
GenFile: *out,
GenFile: genFile,
Dir: *dir,
}, nil
}
Expand Down

0 comments on commit 9c2f3a2

Please sign in to comment.