jmcnamara / libxlsxwriter

A C library for creating Excel XLSX files.
https://libxlsxwriter.github.io
Other
1.49k stars 332 forks source link

Weakness in Set header and footer that can lead to crash #366

Closed gabrielaexile closed 2 years ago

gabrielaexile commented 2 years ago

Hello

Setting header or footer generates error then it will call free(self->footer); in various of places. But it will not set it to NULL, which will cause problem when you come to lxw_worksheet_free where it will again free the footer and header which now are invalid pointers.

jmcnamara commented 2 years ago

Thanks, that looks like a bug. I'll look into it.

jmcnamara commented 2 years ago

I've pushed a fix for this to main if you care to try it out.

There is a failing Windows compilation test but I don't think that it is related. I am debugging it.

jmcnamara commented 2 years ago

The failing test is related so I'll need to look at this a bit more.

jmcnamara commented 2 years ago

I fixed the Windows issue, it was in the test case and not the code. I also did a bit more refactoring to take care of some other edge cases in the header/footer failure modes.

Anyway, let me know if this resolves your issue. I will close the GitHub issue in a few days if there is no update.

jmcnamara commented 2 years ago

Closing. If there are any further issues let me know.