Skip to content

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

Description

@driesdev

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions