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

nil pointer dereference when unmarshalling time.Time to pointer #257

Open
driesdev opened this issue Nov 21, 2019 · 0 comments
Open

nil pointer dereference when unmarshalling time.Time to pointer #257

driesdev opened this issue Nov 21, 2019 · 0 comments

Comments

@driesdev
Copy link

the generated code is

			var tmpJSpecialDates *time.Time

			tok = fs.Scan()
			if tok == fflib.FFTok_error {
				goto tokerror
			}
			if tok == fflib.FFTok_right_brace {
				break
			}

			if tok == fflib.FFTok_comma {
				if wantVal == true {
					// TODO(pquerna): this isn't an ideal error message, this handles
					// things like [,,,] as an array value.
					return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok))
				}
				continue
			} else {
				wantVal = true
			}

			/* handler: tmpJSpecialDates type=*time.Time kind=ptr quoted=false*/

			{
				if tok == fflib.FFTok_null {

				} else {

					tbuf, err := fs.CaptureField(tok)
					if err != nil {
						return fs.WrapErr(err)
					}

					err = tmpJSpecialDates.UnmarshalJSON(tbuf)
					if err != nil {
						return fs.WrapErr(err)
					}
				}
				state = fflib.FFParse_after_value
			}

tmpJSpecialDates here never gets assigned a value, hence when UnmarshalJSON is called on it, it causes a panic.

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