This solution does indeed solve the segfault issue. For learning purposes, I tried to give a little more detail as to why the problem occurs in the first place over here . Feedback is definitely...