Fix errors in src/ that cppcheck yielded with the default configuration

This fixes a number of cppcheck errors that were found in the /src subfolder of supertuxkart.
Note that I modified this (assuming that the exercise is about properly fixing bugs, not only about shutting up cppcheck :) ). If we really run out of memory, then in the following loops memory would be overwritten. I then also reset the number of particles to the previous number.