Changed per your suggestion below but I did add an explicit set of size to zero when sscanf fails because I saw case where size was getting set to looked like -1.