Fix possible memory corruption on insert in fixline buffer

Also, add a test which reproduces this problem. While the test might well
run through even with the buggy version, valgrind will uncover the memory
corruption, and in some cases it can lead to a crash or otherwise undesired
behaviour.