Setting q to p->next leads to an infinite loop if p has at least two
segments. The correct way is to iterate over q so we actually progress
through the list.
Signed-off-by: Florian Schmidt <florian.schmidt@neclab.eu> Reviewed-by: Simon Kuenzer <simon.kuenzer@neclab.eu>