I'm creating a NITF file with multiple bands of image data I have in another raw data file. I am using Band interleaved by Block (i.e. IMODE = "B") but setting the block size to the same size as the image data (i.e. only a single block per band). When I also enabe caching on write (via nitf_ImageWriter_setWriteCaching(...,1) I get a seg fault when trying to write.
I've traced this segfault to line 654 of ImageIO.c:
* Free block buffers if allocated
* This works because of how
* They are allocated
blocks = &(cntlActual->blockIO);
for (i = 0;i < cntlActual->nBlockIO;i++)
if ((blocks[i].blockControl.block != NULL)
It dies on the second free (the pointer is invalid and non-null).
My "workaround" which is ok for now is to just not use caching.