{"action":"created","issue":{"url":"https://api.github.com/repos/neovim/neovim/issues/685","labels_url":"https://api.github.com/repos/neovim/neovim/issues/685/labels{/name}","comments_url":"https://api.github.com/repos/neovim/neovim/issues/685/comments","events_url":"https://api.github.com/repos/neovim/neovim/issues/685/events","html_url":"https://github.com/neovim/neovim/issues/685","id":32775314,"number":685,"title":"Use snprintf to calculate size for allocation before actual snprintf","user":{"login":"ony","id":11265,"avatar_url":"https://avatars.githubusercontent.com/u/11265?v=3","gravatar_id":"","url":"https://api.github.com/users/ony","html_url":"https://github.com/ony","followers_url":"https://api.github.com/users/ony/followers","following_url":"https://api.github.com/users/ony/following{/other_user}","gists_url":"https://api.github.com/users/ony/gists{/gist_id}","starred_url":"https://api.github.com/users/ony/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ony/subscriptions","organizations_url":"https://api.github.com/users/ony/orgs","repos_url":"https://api.github.com/users/ony/repos","events_url":"https://api.github.com/users/ony/events{/privacy}","received_events_url":"https://api.github.com/users/ony/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":{"login":"justinmk","id":1359421,"avatar_url":"https://avatars.githubusercontent.com/u/1359421?v=3","gravatar_id":"","url":"https://api.github.com/users/justinmk","html_url":"https://github.com/justinmk","followers_url":"https://api.github.com/users/justinmk/followers","following_url":"https://api.github.com/users/justinmk/following{/other_user}","gists_url":"https://api.github.com/users/justinmk/gists{/gist_id}","starred_url":"https://api.github.com/users/justinmk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/justinmk/subscriptions","organizations_url":"https://api.github.com/users/justinmk/orgs","repos_url":"https://api.github.com/users/justinmk/repos","events_url":"https://api.github.com/users/justinmk/events{/privacy}","received_events_url":"https://api.github.com/users/justinmk/received_events","type":"User","site_admin":false},"milestone":null,"comments":3,"created_at":"2014-05-04T19:50:58Z","updated_at":"2015-08-18T00:49:07Z","closed_at":"2015-08-18T00:49:07Z","body":"Lets drop that error-prone code [`len += (long_u)STRLEN(itmp) + 9;                    /* \" { < \" + \" } \" */`](https://github.com/neovim/neovim/blob/d1411aebd8c9514a6a5fceaffe6d11f5a8df59f1/src/ex_cmds.c#L1336)\r\nIn favor of something like:\r\n\r\n````c\r\nconst char *fmt = itmp ? \"(%s) < %s\" :\r\n                  otmp ? \"(%s)\" : \"%s\";\r\nsize_t len = vim_snprintf(NULL, 0, fmt, cmd, itmp)\r\n             + otmp ? append_redir(NULL, 0, p_srr, otmp) : 0;\r\nchar *buf = lalloc(len, TRUE);\r\nif (buf == NULL)\r\n  return NULL;\r\n(void) vim_snprintf(buf, len, fmt, cmd, itmp);\r\nif (otmp)\r\n  append_redir(buf, len, p_srr, otmp);\r\nreturn buf;\r\n````\r\n\r\n\r\n<bountysource-plugin>\r\n\r\n---\r\nWant to back this issue? **[Place a bounty on it!](https://www.bountysource.com/issues/1982448-use-snprintf-to-calculate-size-for-allocation-before-actual-snprintf?utm_campaign=plugin&utm_content=tracker%2F461131&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F461131&utm_medium=issues&utm_source=github).\r\n</bountysource-plugin>"},"comment":{"url":"https://api.github.com/repos/neovim/neovim/issues/comments/132006873","html_url":"https://github.com/neovim/neovim/issues/685#issuecomment-132006873","issue_url":"https://api.github.com/repos/neovim/neovim/issues/685","id":132006873,"user":{"login":"justinmk","id":1359421,"avatar_url":"https://avatars.githubusercontent.com/u/1359421?v=3","gravatar_id":"","url":"https://api.github.com/users/justinmk","html_url":"https://github.com/justinmk","followers_url":"https://api.github.com/users/justinmk/followers","following_url":"https://api.github.com/users/justinmk/following{/other_user}","gists_url":"https://api.github.com/users/justinmk/gists{/gist_id}","starred_url":"https://api.github.com/users/justinmk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/justinmk/subscriptions","organizations_url":"https://api.github.com/users/justinmk/orgs","repos_url":"https://api.github.com/users/justinmk/repos","events_url":"https://api.github.com/users/justinmk/events{/privacy}","received_events_url":"https://api.github.com/users/justinmk/received_events","type":"User","site_admin":false},"created_at":"2015-08-18T00:49:07Z","updated_at":"2015-08-18T00:49:07Z","body":"Not sure what to do with this."}}