Check http://cwe.mitre.org/top25/ for some interesting infos on how to prevent and examples for coding bugs...