AndreaCensi/csm — pull request #1 by stwirth (2013-03-19 17:12:53+00:00)
Title: Buffer overflow in math_utils and reordering of MAX_CONTEXT check in egsl.c

I had a strange segfault using your library. It turned out that I had not initialized params.first_guess to some value.
That made the icp_loop access uninitialized memory (some random very high numbers) and the buffer used in egsl_friendly_pose (egsl_tmp_buf) was not big enough to hold the char representation of these numbers. So other memory was overwritten by the sprintf call.
I increased the buffer size so that this does not happen.
I also changed the check for (cid >= MAX_CONTEXTS) in egsl_push_named to happen right after the incrementation and added the same check in the print loop.