hamba / avro

A fast Go Avro codec
MIT License
397 stars 95 forks source link

null pointer exception - decoding "null" type #432

Open vgough opened 3 months ago

vgough commented 3 months ago

Using ocf.NewDecoder(r) on a random avro file, the Decode operation panics due to a null pointer exception from hamba/avro. The issue is that newEfaceDecoder inside codec_dynamic does not check the error of genericReceiver and proceeds with a nil typ value, which causes a null pointer exception later in the code.

One fix could be to add a Null condition in genericReceiver in codec_generic.go:

    case Null:
        return reflect2.TypeOf((*null)(nil)), nil

That at least results in a "avro: schema type null in unsupported" error rather than a NPE. Ideally errors should also not be ignored, and turned into some sort of error upward.

nrwiersma commented 3 months ago

Can you provide a small bit a of code that reproduces the issue?