{"action":"opened","issue":{"url":"https://api.github.com/repos/deater/ansi2gif/issues/3","repository_url":"https://api.github.com/repos/deater/ansi2gif","labels_url":"https://api.github.com/repos/deater/ansi2gif/issues/3/labels{/name}","comments_url":"https://api.github.com/repos/deater/ansi2gif/issues/3/comments","events_url":"https://api.github.com/repos/deater/ansi2gif/issues/3/events","html_url":"https://github.com/deater/ansi2gif/issues/3","id":191874934,"number":3,"title":"Segfault on empty \"set graphics mode\" terminal escape sequence","user":{"login":"sietse","id":271843,"avatar_url":"https://avatars.githubusercontent.com/u/271843?v=3","gravatar_id":"","url":"https://api.github.com/users/sietse","html_url":"https://github.com/sietse","followers_url":"https://api.github.com/users/sietse/followers","following_url":"https://api.github.com/users/sietse/following{/other_user}","gists_url":"https://api.github.com/users/sietse/gists{/gist_id}","starred_url":"https://api.github.com/users/sietse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sietse/subscriptions","organizations_url":"https://api.github.com/users/sietse/orgs","repos_url":"https://api.github.com/users/sietse/repos","events_url":"https://api.github.com/users/sietse/events{/privacy}","received_events_url":"https://api.github.com/users/sietse/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-11-27T17:59:29Z","updated_at":"2016-11-27T17:59:29Z","closed_at":null,"body":"Hi Vince/deater,\r\n\r\nThank you for writing `ansi2gif`, it's a fantastic little program! I've found a case where it crashes, and I thought you might be interested.\r\n\r\nThis minimal crashing example, [escape-left-bracket-m-segfault.ans.txt](https://github.com/deater/ansi2gif/files/614810/escape-left-bracket-m-segfault.ans.txt), contains the terminal escape code `ESC[m`, which causes ansi2gif to segfault.\r\n\r\n`ESC[0m`  is the terminal escape sequence for 'reset graphics mode' or 'reset all color/font attributes'. Unfortulately, some programs instead send `Esc[m`, with nothing instead of a digit. I'm not sure whether this is also allowed by the standard (which I couldn't find *anywhere*), but it [a search on searchcode.com](https://searchcode.com/?q=ESC%5Bm) suggests it is common. Parsing `ESC[m` without crashing, and interpreting it as `ESC[0m`, should fix the issue.\r\n\r\nI'm afraid I don't know enough of C myself to submit a patch. Please don't feel obliged to fix this, though; and thank you for all your work polishing `ansi2gif`.\r\n\r\nKind regards,\r\nSietse\r\n\r\nP.s. Because these terminal escape codes are quite hard to google, and because there is huge fragmentation in how they are spelled out, I'd like to put a few variant spellings here so that future googlers can easily find it.\r\n\r\n`ESC[0m`, `ESC[m`\r\n`ESC [ 0 m`, `ESC [ m`\r\n`\\[[0m`, `\\[[m`,\r\n`^[[0m`, `^[[m`\r\nEscape left bracket zero m, Escape left bracket m\r\nEscape bracket zero m, Escape bracket m."}}
{"actor":{"display_login":"sietse"}}