{"action":"created","comment":{"url":"https://api.github.com/repos/ThePowderToy/The-Powder-Toy/pulls/comments/190197717","pull_request_review_id":122518659,"id":190197717,"diff_hunk":"@@ -230,51 +227,40 @@ pixel *Graphics::ptif_unpack(void *datain, int size, int *w, int *h){\n \t\tprintf(\"Image header invalid\\n\");\n \t\treturn NULL;\n \t}\n-\twidth = data[4]|(data[5]<<8);\n-\theight = data[6]|(data[7]<<8);\n-\n-\ti = (width*height)*3;\n-\tundata = (unsigned char*)calloc(1, (width*height)*3);\n-\tred_chan = (unsigned char*)calloc(1, width*height);\n-\tgreen_chan = (unsigned char*)calloc(1, width*height);\n-\tblue_chan = (unsigned char *)calloc(1, width*height);\n+\tint width = data[4]|(data[5]<<8);\n+\tint height = data[6]|(data[7]<<8);\n+\n+\tint i = (width*height)*3;\n+\n+\tauto red_chan = std::vector<unsigned char>(width*height);\n+\tauto green_chan = std::vector<unsigned char>(width*height);\n+\tauto blue_chan = std::vector<unsigned char>(width*height);\n+\tauto undata = std::vector<unsigned char>(width*height * 3);\n+\n \tresult = (pixel *)calloc(width*height, PIXELSIZE);\n \n-\tresCode = BZ2_bzBuffToBuffDecompress((char *)undata, (unsigned *)&i, (char *)(data+8), size-8, 0, 0);\n+\tint resCode = BZ2_bzBuffToBuffDecompress((char *)undata.data(), (unsigned *)&i, (char *)(data.data()+8), size-8, 0, 0);\n \tif (resCode){\n \t\tprintf(\"Decompression failure, %d\\n\", resCode);\n-\t\tfree(red_chan);\n-\t\tfree(green_chan);\n-\t\tfree(blue_chan);\n-\t\tfree(undata);\n-\t\tfree(result);\n \t\treturn NULL;\n \t}\n \tif(i != (width*height)*3){\n \t\tprintf(\"Result buffer size mismatch, %d != %d\\n\", i, (width*height)*3);\n-\t\tfree(red_chan);\n-\t\tfree(green_chan);\n-\t\tfree(blue_chan);\n-\t\tfree(undata);\n-\t\tfree(result);\n \t\treturn NULL;\n \t}\n-\tmemcpy(red_chan, undata, width*height);\n-\tmemcpy(green_chan, undata+(width*height), width*height);\n-\tmemcpy(blue_chan, undata+((width*height)*2), width*height);\n+\tstd::copy(undata.begin(), undata.begin()+width*height, red_chan.end());","path":"src/graphics/Graphics.cpp","position":128,"original_position":128,"commit_id":"ed39bd08fa083384aa6b1c9a9eb51828f621d66e","original_commit_id":"ed39bd08fa083384aa6b1c9a9eb51828f621d66e","user":{"login":"mniip","id":1322658,"avatar_url":"https://avatars3.githubusercontent.com/u/1322658?v=4","gravatar_id":"","url":"https://api.github.com/users/mniip","html_url":"https://github.com/mniip","followers_url":"https://api.github.com/users/mniip/followers","following_url":"https://api.github.com/users/mniip/following{/other_user}","gists_url":"https://api.github.com/users/mniip/gists{/gist_id}","starred_url":"https://api.github.com/users/mniip/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mniip/subscriptions","organizations_url":"https://api.github.com/users/mniip/orgs","repos_url":"https://api.github.com/users/mniip/repos","events_url":"https://api.github.com/users/mniip/events{/privacy}","received_events_url":"https://api.github.com/users/mniip/received_events","type":"User","site_admin":false},"body":"Writes outside of the vector.","created_at":"2018-05-23T10:29:22Z","updated_at":"2018-05-23T10:43:52Z","html_url":"https://github.com/ThePowderToy/The-Powder-Toy/pull/573#discussion_r190197717","pull_request_url":"https://api.github.com/repos/ThePowderToy/The-Powder-Toy/pulls/573","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/ThePowderToy/The-Powder-Toy/pulls/comments/190197717"},"html":{"href":"https://github.com/ThePowderToy/The-Powder-Toy/pull/573#discussion_r190197717"},"pull_request":{"href":"https://api.github.com/repos/ThePowderToy/The-Powder-Toy/pulls/573"}}},"pull_request":{"url":"https://api.github.com/repos/ThePowderToy/The-Powder-Toy/pulls/573","id":189671346,"html_url":"https://github.com/ThePowderToy/The-Powder-Toy/pull/573","diff_url":"https://github.com/ThePowderToy/The-Powder-Toy/pull/573.diff","patch_url":"https://github.com/ThePowderToy/The-Powder-Toy/pull/573.patch","issue_url":"https://api.github.com/repos/ThePowderToy/The-Powder-Toy/issues/573","number":573,"state":"open","locked":false,"title":"Issue #570","user":{"login":"Jack-Punter","id":38081812,"avatar_url":"https://avatars1.githubusercontent.com/u/38081812?v=4","gravatar_id":"","url":"https://api.github.com/users/Jack-Punter","html_url":"https://github.com/Jack-Punter","followers_url":"https://api.github.com/users/Jack-Punter/followers","following_url":"https://api.github.com/users/Jack-Punter/following{/other_user}","gists_url":"https://api.github.com/users/Jack-Punter/gists{/gist_id}","starred_url":"https://api.github.com/users/Jack-Punter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Jack-Punter/subscriptions","organizations_url":"https://api.github.com/users/Jack-Punter/orgs","repos_url":"https://api.github.com/users/Jack-Punter/repos","events_url":"https://api.github.com/users/Jack-Punter/events{/privacy}","received_events_url":"https://api.github.com/users/Jack-Punter/received_events","type":"User","site_admin":false},"body":"All changes relating to issue #570. removed many C-strings in favour of String and ByteString, there are some cases where vectors, where used as it, seemed more applicable in the context. Doesn't build on my machine as I removed a #undef max in strings.h. I believe this issue is known about.\r\n\r\nNot checked off all of the file mentioned in the issue but making a PR because I won't be able to make changes for a while so this way people will be able to see what I have done.","created_at":"2018-05-22T13:54:27Z","updated_at":"2018-05-23T10:43:52Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2ed38f24969cd438e78cf11528d84f9e58192882","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/ThePowderToy/The-Powder-Toy/pulls/573/commits","review_comments_url":"https://api.github.com/repos/ThePowderToy/The-Powder-Toy/pulls/573/comments","review_comment_url":"https://api.github.com/repos/ThePowderToy/The-Powder-Toy/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ThePowderToy/The-Powder-Toy/issues/573/comments","statuses_url":"https://api.github.com/repos/ThePowderToy/The-Powder-Toy/statuses/ed39bd08fa083384aa6b1c9a9eb51828f621d66e","head":{"label":"Jack-Punter:Issue_#570","ref":"Issue_#570","sha":"ed39bd08fa083384aa6b1c9a9eb51828f621d66e","user":{"login":"Jack-Punter","id":38081812,"avatar_url":"https://avatars1.githubusercontent.com/u/38081812?v=4","gravatar_id":"","url":"https://api.github.com/users/Jack-Punter","html_url":"https://github.com/Jack-Punter","followers_url":"https://api.github.com/users/Jack-Punter/followers","following_url":"https://api.github.com/users/Jack-Punter/following{/other_user}","gists_url":"https://api.github.com/users/Jack-Punter/gists{/gist_id}","starred_url":"https://api.github.com/users/Jack-Punter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Jack-Punter/subscriptions","organizations_url":"https://api.github.com/users/Jack-Punter/orgs","repos_url":"https://api.github.com/users/Jack-Punter/repos","events_url":"https://api.github.com/users/Jack-Punter/events{/privacy}","received_events_url":"https://api.github.com/users/Jack-Punter/received_events","type":"User","site_admin":false},"repo":{"id":133270272,"name":"The-Powder-Toy","full_name":"Jack-Punter/The-Powder-Toy","owner":{"login":"Jack-Punter","id":38081812,"avatar_url":"https://avatars1.githubusercontent.com/u/38081812?v=4","gravatar_id":"","url":"https://api.github.com/users/Jack-Punter","html_url":"https://github.com/Jack-Punter","followers_url":"https://api.github.com/users/Jack-Punter/followers","following_url":"https://api.github.com/users/Jack-Punter/following{/other_user}","gists_url":"https://api.github.com/users/Jack-Punter/gists{/gist_id}","starred_url":"https://api.github.com/users/Jack-Punter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Jack-Punter/subscriptions","organizations_url":"https://api.github.com/users/Jack-Punter/orgs","repos_url":"https://api.github.com/users/Jack-Punter/repos","events_url":"https://api.github.com/users/Jack-Punter/events{/privacy}","received_events_url":"https://api.github.com/users/Jack-Punter/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Jack-Punter/The-Powder-Toy","description":"Written in C++ and using SDL, The Powder Toy is a desktop version of the classic 'falling sand' physics sandbox, it simulates air pressure and velocity as well as heat.","fork":true,"url":"https://api.github.com/repos/Jack-Punter/The-Powder-Toy","forks_url":"https://api.github.com/repos/Jack-Punter/The-Powder-Toy/forks","keys_url":"https://api.github.com/repos/Jack-Punter/The-Powder-Toy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Jack-Punter/The-Powder-Toy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Jack-Punter/The-Powder-Toy/teams","hooks_url":"https://api.github.com/repos/Jack-Punter/The-Powder-Toy/hooks","issue_events_url":"https://api.github.com/repos/Jack-Punter/The-Powder-Toy/issues/events{/number}","events_url":"https://api.github.com/repos/Jack-Punter/The-Powder-Toy/events","assignees_url":"https://api.github.com/repos/Jack-Punter/The-Powder-Toy/assignees{/user}","branches_url":"https://api.github.com/repos/Jack-Punter/The-Powder-Toy/branches{/branch}","tags_url":"https://api.github.com/repos/Jack-Punter/The-Powder-Toy/tags","blobs_url":"https://api.github.com/repos/Jack-Punter/The-Powder-Toy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Jack-Punter/The-Powder-Toy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Jack-Punter/The-Powder-Toy/git/refs{/sha}","trees_url":"https://api.github.com/repos/Jack-Punter/The-Powder-Toy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Jack-Punter/The-Powder-Toy/statuses/{sha}","languages_url":"https://api.github.com/repos/Jack-Punter/The-Powder-Toy/languages","stargazers_url":"https://api.github.com/repos/Jack-Punter/The-Powder-Toy/stargazers","contributors_url":"https://api.github.com/repos/Jack-Punter/The-Powder-Toy/contributors","subscribers_url":"https://api.github.com/repos/Jack-Punter/The-Powder-Toy/subscribers","subscription_url":"https://api.github.com/repos/Jack-Punter/The-Powder-Toy/subscription","commits_url":"https://api.github.com/repos/Jack-Punter/The-Powder-Toy/commits{/sha}","git_commits_url":"https://api.github.com/repos/Jack-Punter/The-Powder-Toy/git/commits{/sha}","comments_url":"https://api.github.com/repos/Jack-Punter/The-Powder-Toy/comments{/number}","issue_comment_url":"https://api.github.com/repos/Jack-Punter/The-Powder-Toy/issues/comments{/number}","contents_url":"https://api.github.com/repos/Jack-Punter/The-Powder-Toy/contents/{+path}","compare_url":"https://api.github.com/repos/Jack-Punter/The-Powder-Toy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Jack-Punter/The-Powder-Toy/merges","archive_url":"https://api.github.com/repos/Jack-Punter/The-Powder-Toy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Jack-Punter/The-Powder-Toy/downloads","issues_url":"https://api.github.com/repos/Jack-Punter/The-Powder-Toy/issues{/number}","pulls_url":"https://api.github.com/repos/Jack-Punter/The-Powder-Toy/pulls{/number}","milestones_url":"https://api.github.com/repos/Jack-Punter/The-Powder-Toy/milestones{/number}","notifications_url":"https://api.github.com/repos/Jack-Punter/The-Powder-Toy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Jack-Punter/The-Powder-Toy/labels{/name}","releases_url":"https://api.github.com/repos/Jack-Punter/The-Powder-Toy/releases{/id}","deployments_url":"https://api.github.com/repos/Jack-Punter/The-Powder-Toy/deployments","created_at":"2018-05-13T20:04:06Z","updated_at":"2018-05-16T00:52:07Z","pushed_at":"2018-05-22T12:41:32Z","git_url":"git://github.com/Jack-Punter/The-Powder-Toy.git","ssh_url":"git@github.com:Jack-Punter/The-Powder-Toy.git","clone_url":"https://github.com/Jack-Punter/The-Powder-Toy.git","svn_url":"https://github.com/Jack-Punter/The-Powder-Toy","homepage":"http://powdertoy.co.uk","size":27358,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"gpl-3.0","name":"GNU General Public License v3.0","spdx_id":"GPL-3.0","url":"https://api.github.com/licenses/gpl-3.0"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"ThePowderToy:master","ref":"master","sha":"38fac7046a7a5b4837eba968e6c0c1a7e303ee01","user":{"login":"ThePowderToy","id":2064613,"avatar_url":"https://avatars1.githubusercontent.com/u/2064613?v=4","gravatar_id":"","url":"https://api.github.com/users/ThePowderToy","html_url":"https://github.com/ThePowderToy","followers_url":"https://api.github.com/users/ThePowderToy/followers","following_url":"https://api.github.com/users/ThePowderToy/following{/other_user}","gists_url":"https://api.github.com/users/ThePowderToy/gists{/gist_id}","starred_url":"https://api.github.com/users/ThePowderToy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ThePowderToy/subscriptions","organizations_url":"https://api.github.com/users/ThePowderToy/orgs","repos_url":"https://api.github.com/users/ThePowderToy/repos","events_url":"https://api.github.com/users/ThePowderToy/events{/privacy}","received_events_url":"https://api.github.com/users/ThePowderToy/received_events","type":"Organization","site_admin":false},"repo":{"id":796532,"name":"The-Powder-Toy","full_name":"ThePowderToy/The-Powder-Toy","owner":{"login":"ThePowderToy","id":2064613,"avatar_url":"https://avatars1.githubusercontent.com/u/2064613?v=4","gravatar_id":"","url":"https://api.github.com/users/ThePowderToy","html_url":"https://github.com/ThePowderToy","followers_url":"https://api.github.com/users/ThePowderToy/followers","following_url":"https://api.github.com/users/ThePowderToy/following{/other_user}","gists_url":"https://api.github.com/users/ThePowderToy/gists{/gist_id}","starred_url":"https://api.github.com/users/ThePowderToy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ThePowderToy/subscriptions","organizations_url":"https://api.github.com/users/ThePowderToy/orgs","repos_url":"https://api.github.com/users/ThePowderToy/repos","events_url":"https://api.github.com/users/ThePowderToy/events{/privacy}","received_events_url":"https://api.github.com/users/ThePowderToy/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ThePowderToy/The-Powder-Toy","description":"Written in C++ and using SDL, The Powder Toy is a desktop version of the classic 'falling sand' physics sandbox, it simulates air pressure and velocity as well as heat.","fork":false,"url":"https://api.github.com/repos/ThePowderToy/The-Powder-Toy","forks_url":"https://api.github.com/repos/ThePowderToy/The-Powder-Toy/forks","keys_url":"https://api.github.com/repos/ThePowderToy/The-Powder-Toy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ThePowderToy/The-Powder-Toy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ThePowderToy/The-Powder-Toy/teams","hooks_url":"https://api.github.com/repos/ThePowderToy/The-Powder-Toy/hooks","issue_events_url":"https://api.github.com/repos/ThePowderToy/The-Powder-Toy/issues/events{/number}","events_url":"https://api.github.com/repos/ThePowderToy/The-Powder-Toy/events","assignees_url":"https://api.github.com/repos/ThePowderToy/The-Powder-Toy/assignees{/user}","branches_url":"https://api.github.com/repos/ThePowderToy/The-Powder-Toy/branches{/branch}","tags_url":"https://api.github.com/repos/ThePowderToy/The-Powder-Toy/tags","blobs_url":"https://api.github.com/repos/ThePowderToy/The-Powder-Toy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ThePowderToy/The-Powder-Toy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ThePowderToy/The-Powder-Toy/git/refs{/sha}","trees_url":"https://api.github.com/repos/ThePowderToy/The-Powder-Toy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ThePowderToy/The-Powder-Toy/statuses/{sha}","languages_url":"https://api.github.com/repos/ThePowderToy/The-Powder-Toy/languages","stargazers_url":"https://api.github.com/repos/ThePowderToy/The-Powder-Toy/stargazers","contributors_url":"https://api.github.com/repos/ThePowderToy/The-Powder-Toy/contributors","subscribers_url":"https://api.github.com/repos/ThePowderToy/The-Powder-Toy/subscribers","subscription_url":"https://api.github.com/repos/ThePowderToy/The-Powder-Toy/subscription","commits_url":"https://api.github.com/repos/ThePowderToy/The-Powder-Toy/commits{/sha}","git_commits_url":"https://api.github.com/repos/ThePowderToy/The-Powder-Toy/git/commits{/sha}","comments_url":"https://api.github.com/repos/ThePowderToy/The-Powder-Toy/comments{/number}","issue_comment_url":"https://api.github.com/repos/ThePowderToy/The-Powder-Toy/issues/comments{/number}","contents_url":"https://api.github.com/repos/ThePowderToy/The-Powder-Toy/contents/{+path}","compare_url":"https://api.github.com/repos/ThePowderToy/The-Powder-Toy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ThePowderToy/The-Powder-Toy/merges","archive_url":"https://api.github.com/repos/ThePowderToy/The-Powder-Toy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ThePowderToy/The-Powder-Toy/downloads","issues_url":"https://api.github.com/repos/ThePowderToy/The-Powder-Toy/issues{/number}","pulls_url":"https://api.github.com/repos/ThePowderToy/The-Powder-Toy/pulls{/number}","milestones_url":"https://api.github.com/repos/ThePowderToy/The-Powder-Toy/milestones{/number}","notifications_url":"https://api.github.com/repos/ThePowderToy/The-Powder-Toy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ThePowderToy/The-Powder-Toy/labels{/name}","releases_url":"https://api.github.com/repos/ThePowderToy/The-Powder-Toy/releases{/id}","deployments_url":"https://api.github.com/repos/ThePowderToy/The-Powder-Toy/deployments","created_at":"2010-07-25T13:47:06Z","updated_at":"2018-05-23T09:38:32Z","pushed_at":"2018-05-22T13:54:28Z","git_url":"git://github.com/ThePowderToy/The-Powder-Toy.git","ssh_url":"git@github.com:ThePowderToy/The-Powder-Toy.git","clone_url":"https://github.com/ThePowderToy/The-Powder-Toy.git","svn_url":"https://github.com/ThePowderToy/The-Powder-Toy","homepage":"http://powdertoy.co.uk","size":27322,"stargazers_count":1335,"watchers_count":1335,"language":"C++","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":493,"mirror_url":null,"archived":false,"open_issues_count":39,"license":{"key":"gpl-3.0","name":"GNU General Public License v3.0","spdx_id":"GPL-3.0","url":"https://api.github.com/licenses/gpl-3.0"},"forks":493,"open_issues":39,"watchers":1335,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ThePowderToy/The-Powder-Toy/pulls/573"},"html":{"href":"https://github.com/ThePowderToy/The-Powder-Toy/pull/573"},"issue":{"href":"https://api.github.com/repos/ThePowderToy/The-Powder-Toy/issues/573"},"comments":{"href":"https://api.github.com/repos/ThePowderToy/The-Powder-Toy/issues/573/comments"},"review_comments":{"href":"https://api.github.com/repos/ThePowderToy/The-Powder-Toy/pulls/573/comments"},"review_comment":{"href":"https://api.github.com/repos/ThePowderToy/The-Powder-Toy/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ThePowderToy/The-Powder-Toy/pulls/573/commits"},"statuses":{"href":"https://api.github.com/repos/ThePowderToy/The-Powder-Toy/statuses/ed39bd08fa083384aa6b1c9a9eb51828f621d66e"}},"author_association":"NONE"}}
{"actor":{"display_login":"mniip"}}