mirror of
https://github.com/jmcnamara/libxlsxwriter.git
synced 2026-05-15 14:15:54 -06:00
[GH-ISSUE #61] Potential problem with ownership of page breaks #54
Labels
No labels
awaiting user feedback
bug
cmake
cmake
docs
feature request
in progress
long term
medium term
medium term
pull-request
question
question
ready to close
short term
under investigation
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/libxlsxwriter#54
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @utelle on GitHub (Jul 4, 2016).
Original GitHub issue: https://github.com/jmcnamara/libxlsxwriter/issues/61
Originally assigned to: @jmcnamara on GitHub.
The
worksheetfunctionsworksheet_set_h_pagebreaksandworksheet_set_v_pagebreakstake anlxw_row_tresplxw_col_tarray. However, those functions don't take ownership of the arrays, they just set a reference to them in theworksheetdata structure. Thus, the programmer has to ensure that the page break array doesn't go out of scope while theworksheetis processed. That is, the following simple example, where the page break array is declared within a function and goes out of scope as soon as the function is left, would show unpredictable behaviour (or might even crash) later on:I think it would be better if the
worksheetwould take ownership of the arrays by making copies of them and storing the copies internally (just as is done for strings which are duplicated usingstrdup).You could argue "just don't declare these arrays in a way that they could go out of scope". However, for the C++ wrapper classes I currently implement this imposes a real problem. The page break array is passed to the wrapper in a different data structure and the
lxw_row_tarray would be created on the fly, but this would not work at the moment. The wrapper class would have to take measures to ensure the lifetime of the created arrays somehow, i.e. persist the arrays within the wrapper class. Not impossible, but cumbersome, and probably error-prone.@jmcnamara commented on GitHub (Jul 4, 2016):
Actually, I wouldn't argue that. :-)
In almost all cases I try to copy the user data in case it goes out of scope. However, I missed this one (and possibly others).
I'll fix it.
@utelle commented on GitHub (Jul 4, 2016):
Thanks.
I will continue to report issues, if I come across them.
@jmcnamara commented on GitHub (Jul 4, 2016):
Fixed on master.
@jmcnamara commented on GitHub (Jul 4, 2016):
Fixed in release 0.4.0. Thanks for the report.