[sword-devel] Crash when getting module type
David "Judah's Shadow" Blue
yudahsshadow at gmx.com
Thu Oct 26 13:59:34 EDT 2023
On Wednesday, October 25, 2023 6:22:54 PM EDT Donna Whisnant wrote:
> David,
>
> Based on the code you are showing, I can pretty much guarantee you that your
> segfault is caused by tempMod being a null pointer -- i.e. that the value
> of the map element you are iterating is null.
Ok, I didn't know that there could be null elements in the map.
> Your code needs to be more defensive and check if tempMod is a nullptr
> before dereferencing it. Adding an 'if' around that code block should fix
> your segfault problem.
> But you'll have to determine why some module
> entries in your map are nulls -- perhaps you missed loading modules or
> something? Your code snippet doesn't show any of those details... it only
> shows iterating something that appears to be a std::map.
Do you have to do something to load modules? When my program initializes, I do
this
swordLibrary = new sword::SWMgr(new sword::MarkupFilterMgr(sword::FMT_PLAIN));
and then pass a pointer to that around my various classes.
In this particular function, the iterator is this,
sword::ModMap::iterator libraryIterator;
I had thought I was following one of the examples.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part.
URL: <http://crosswire.org/pipermail/sword-devel/attachments/20231026/9e72cee0/attachment.sig>
More information about the sword-devel
mailing list