mirror of
https://github.com/mikefarah/yq.git
synced 2025-01-24 23:20:05 +00:00
Fix Seg Fault on bad split expression input #1086
This commit is contained in:
parent
a9e7f669d0
commit
71242b0c8e
@ -84,7 +84,10 @@ func evaluateAll(cmd *cobra.Command, args []string) (cmdError error) {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
printerWriter := configurePrinterWriter(format, out)
|
printerWriter, err := configurePrinterWriter(format, out)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
encoder := configureEncoder(format)
|
encoder := configureEncoder(format)
|
||||||
|
|
||||||
printer := yqlib.NewPrinter(encoder, printerWriter)
|
printer := yqlib.NewPrinter(encoder, printerWriter)
|
||||||
|
@ -92,7 +92,10 @@ func evaluateSequence(cmd *cobra.Command, args []string) (cmdError error) {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
printerWriter := configurePrinterWriter(format, out)
|
printerWriter, err := configurePrinterWriter(format, out)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
encoder := configureEncoder(format)
|
encoder := configureEncoder(format)
|
||||||
|
|
||||||
printer := yqlib.NewPrinter(encoder, printerWriter)
|
printer := yqlib.NewPrinter(encoder, printerWriter)
|
||||||
|
@ -57,7 +57,7 @@ func configureDecoder() (yqlib.Decoder, error) {
|
|||||||
return yqlib.NewYamlDecoder(), nil
|
return yqlib.NewYamlDecoder(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func configurePrinterWriter(format yqlib.PrinterOutputFormat, out io.Writer) yqlib.PrinterWriter {
|
func configurePrinterWriter(format yqlib.PrinterOutputFormat, out io.Writer) (yqlib.PrinterWriter, error) {
|
||||||
|
|
||||||
var printerWriter yqlib.PrinterWriter
|
var printerWriter yqlib.PrinterWriter
|
||||||
|
|
||||||
@ -65,13 +65,13 @@ func configurePrinterWriter(format yqlib.PrinterOutputFormat, out io.Writer) yql
|
|||||||
colorsEnabled = forceColor
|
colorsEnabled = forceColor
|
||||||
splitExp, err := yqlib.NewExpressionParser().ParseExpression(splitFileExp)
|
splitExp, err := yqlib.NewExpressionParser().ParseExpression(splitFileExp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil
|
return nil, fmt.Errorf("bad split document expression: %w", err)
|
||||||
}
|
}
|
||||||
printerWriter = yqlib.NewMultiPrinterWriter(splitExp, format)
|
printerWriter = yqlib.NewMultiPrinterWriter(splitExp, format)
|
||||||
} else {
|
} else {
|
||||||
printerWriter = yqlib.NewSinglePrinterWriter(out)
|
printerWriter = yqlib.NewSinglePrinterWriter(out)
|
||||||
}
|
}
|
||||||
return printerWriter
|
return printerWriter, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func configureEncoder(format yqlib.PrinterOutputFormat) yqlib.Encoder {
|
func configureEncoder(format yqlib.PrinterOutputFormat) yqlib.Encoder {
|
||||||
|
Loading…
Reference in New Issue
Block a user