Re: Crash when getting module type

"David \"Judah's Shadow\" Blue" <[email protected]>
Newsgroups gmane.comp.literature.sword.devel
Message-ID <12316331.O9o76ZdvQC@brooks>
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.

_______________________________________________
sword-devel mailing list: [email protected]
http://crosswire.org/mailman/listinfo/sword-devel
Instructions to unsubscribe/change your settings at above page
signature.asc (application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAABCAAdFiEE2HjGsPT4oPc9mpWEx/nqiX8H6VAFAmU6qQYACgkQx/nqiX8H
6VDtPw//VVIOPcn+SkjVp6BTbpm9+i8wChTh+hoikufDVnscSPWEckxQO/2ou+d4
CS7c2bzqtLY8TuYQQaW98sAEquQXAq9+kMY3ZTCQQYZRt0b4HS0oJROAhjUytp0R
+fbf+50Y8aHpQ1R5K0eChSSWs0BM0jjhAeyzQ3Vz81FMStkP4JpX1HLOkEA9ohhb
3n2TnH3F2Aye0UPDL9KxI3lDDVnwoPLSVVPFn2s3K35FVI4Pek4u7d/t+RKcp3YG
Y3VEGCOtOEYG2dgYmJyuDfPHDEOd7UCQ5YGYrK/rsSWbLLEuV2nDR0uimX01Yvzz
OkeH1T8lPh6RXZGkX3rBqDWN/F6B1ofeFcV2nnulY/ASB1vOa+F5PVl6LCrr0sNX
kzUDseOPmF7/90C/uZx/OLJUYXQ8S3wCPhvBJrXT9hqFxVl4LgW7PxFewDEXptlG
XCtBkxwgD9QCfPD/GT7vNUyIUzlFCcIJkjmswl137G3NMJTgbEQcJGFwSYZ3Znii
a67cwwAr3S2Wu3ueA193Jg5/f1Hoaewmi8bLSDDT2VsgWDJVL6DrYvWfZ5VgBvGa
hgDmHY6GQZ3hEXP+W1dArt6uOeM9/WIbo5APaMUxZqpRCNm2ZMy31I02o89x7weF
3PwTuH5bFwLpAbh1xuLRCS5us1EFwfD6aky7FsSlPJfDXR0igFA=
=7tbv
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.