Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect Error Message in float64 Method in decode_number.go #352

Open
funplusxxx opened this issue Sep 22, 2023 · 0 comments
Open

Incorrect Error Message in float64 Method in decode_number.go #352

funplusxxx opened this issue Sep 22, 2023 · 0 comments

Comments

@funplusxxx
Copy link

Hello,

I was going through the source code of msgpack and noticed a potential issue in the float64 method in the decode_number.go file.

Here is the code snippet:

func (d *Decoder) float64(c codes.Code) (float64, error) {
	switch c {
	case codes.Float:
		n, err := d.float32(c)
		if err != nil {
			return 0, err
		}
		return float64(n), nil
	case codes.Double:
		n, err := d.uint64()
		if err != nil {
			return 0, err
		}
		return math.Float64frombits(n), nil
	}

	n, err := d.int(c)
	if err != nil {
		return 0, fmt.Errorf("msgpack: invalid code=%x decoding float32", c)
	}
	return float64(n), nil
}


In the error message of the last fmt.Errorf, it says "decoding float32", but it should be "decoding float64" as the method is for decoding a float64 value.

The corrected error message should be:

return 0, fmt.Errorf("msgpack: invalid code=%x decoding float64", c)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant