Unlimited reader stack growth with SERD_NQUADS
Hi, when in n-quads parsing mode the reader grows its internal stack indefinitely.
Version: 0.32.6
How to reproduce
-
Place
printf("Push: %fGiB\n", stack->buf_size / 1024.0 / 1024.0 / 1024.0);
in this branch https://gitlab.com/drobilla/serd/-/blob/main/src/stack.h?ref_type=heads#L54 -
Run
// The only really relevant thing is SERD_NQUADS SerdReader *rdr = serd_reader_new(SERD_NQUADS, NULL, NULL, NULL, NULL, NULL, NULL); // tested with yago4english-no-literals-hermit-inf.nt (~40Mio triples) serd_reader_read_file(rdr, (uint8_t const *) "large-ntriples-file.nt"); serd_reader_free(rdr); -
Example Output
Push: 0.000006GiB [..] Push: 1.645810GiB Push: 2.468715GiB Push: 3.703072GiB Push: 5.554609GiB Push: 8.331913GiB
Expected Behaviour
In SERD_NTRIPLES mode the stack never grows beyond the initial 4096byte allocation.