Fixed infinite loop and added checks for the sscanf result.
Fixed infinite loop and added checks for the sscanf result.

kwm81/ImageMagick,UniQP/ImageMagick,UniQP/ImageMagick,kwm81/ImageMagick,Danack/ImageMagick,Danack/ImageMagick,UniQP/ImageMagick,Danack/ImageMagick,Danack/ImageMagick,kwm81/ImageMagick,UniQP/ImageMagick,kwm81/ImageMagick,kwm81/ImageMagick,kwm81/ImageMagick,UniQP/ImageMagick,UniQP/ImageMagick,Danack/ImageMagick,Danack/ImageMagick