Skip to content

Commit b191d33

Browse files
committed
cmd/gotext: fix segfault in extract & rewrite commands
If extract or rewrite are called with no arguments it results in a segmentation fault, since we dereference the out flag that is not defined for these commands. Fixes golang/go#62697
1 parent f488e19 commit b191d33

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

cmd/gotext/main.go

+8-1
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,18 @@ func config() (*pipeline.Config, error) {
4848
if err != nil {
4949
return nil, wrap(err, "invalid srclang")
5050
}
51+
52+
// Use a default value since rewrite and extract don't have an out flag.
53+
genFile := ""
54+
if out != nil {
55+
genFile = *out
56+
}
57+
5158
return &pipeline.Config{
5259
SourceLanguage: tag,
5360
Supported: getLangs(),
5461
TranslationsPattern: `messages\.(.*)\.json$`,
55-
GenFile: *out,
62+
GenFile: genFile,
5663
Dir: *dir,
5764
}, nil
5865
}

0 commit comments

Comments
 (0)