Bug Hunting Expedition

I used Clang 3.4 (SVN) static analyzer to find these bugs. All commits are bug fixes or related to running Geany under the static analyzer. I tried to be careful to fix the code correctly but I would appreciate someone second look.

I left two or three bugs it found in Scintilla code because I didn't want to change just our local copy. I might get to sending a patch upstream for them, but they're not really bad ones.