bug2(): suggested solution: always prepare enough memory for string handling
bug3(): suggested solution: do not try to free a un-allocated pointer

Please refer to: http://wiki.osdev.org/Beginner_Mistakes#Strings