{"action":"created","comment":{"url":"https://api.github.com/repos/xiph/speexdsp/pulls/comments/62430287","id":62430287,"diff_hunk":"@@ -585,6 +589,20 @@ static int resampler_basic_zero(SpeexResamplerState *st, spx_uint32_t channel_in\n    return out_sample;\n }\n \n+static int mult_div_safe(spx_uint32_t value, spx_uint32_t mul, spx_uint32_t div)\n+{\n+  spx_uint32_t major = value / div;\n+  spx_uint32_t remainder = value % div;\n+  return remainder <= UINT32_MAX / mul && major <= UINT32_MAX / mul;\n+}\n+\n+static int safer_mult_div(spx_uint32_t value, spx_uint32_t mul, spx_uint32_t div)\n+{\n+  spx_uint32_t major = value / div;\n+  spx_uint32_t remainder = value % div;\n+  return remainder * mul / div + major * mul;\n+}\n+","path":"libspeexdsp/resample.c","position":28,"original_position":28,"commit_id":"9b2240c36ea5e1c42ae5602cff427b9c40cdd3f5","original_commit_id":"9b2240c36ea5e1c42ae5602cff427b9c40cdd3f5","user":{"login":"jyavenard","id":505748,"avatar_url":"https://avatars.githubusercontent.com/u/505748?v=3","gravatar_id":"","url":"https://api.github.com/users/jyavenard","html_url":"https://github.com/jyavenard","followers_url":"https://api.github.com/users/jyavenard/followers","following_url":"https://api.github.com/users/jyavenard/following{/other_user}","gists_url":"https://api.github.com/users/jyavenard/gists{/gist_id}","starred_url":"https://api.github.com/users/jyavenard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jyavenard/subscriptions","organizations_url":"https://api.github.com/users/jyavenard/orgs","repos_url":"https://api.github.com/users/jyavenard/repos","events_url":"https://api.github.com/users/jyavenard/events{/privacy}","received_events_url":"https://api.github.com/users/jyavenard/received_events","type":"User","site_admin":false},"body":"We could. I wasn't aware of that one that's all\r\n\r\nHowever, it's 2016 and last I use that other algorithm was about 18 years ago with 4 bits CPU :)\r\n\r\nMost CPUs have mul and div operator these days! So inefficient! The _muldiv generated code will be far slower (and bigger)\r\n\r\nThey aren't safer than one another. They can still overflow just as much.","created_at":"2016-05-08T11:05:45Z","updated_at":"2016-05-08T11:05:45Z","html_url":"https://github.com/xiph/speexdsp/pull/2#discussion_r62430287","pull_request_url":"https://api.github.com/repos/xiph/speexdsp/pulls/2","_links":{"self":{"href":"https://api.github.com/repos/xiph/speexdsp/pulls/comments/62430287"},"html":{"href":"https://github.com/xiph/speexdsp/pull/2#discussion_r62430287"},"pull_request":{"href":"https://api.github.com/repos/xiph/speexdsp/pulls/2"}}},"pull_request":{"url":"https://api.github.com/repos/xiph/speexdsp/pulls/2","id":69241046,"html_url":"https://github.com/xiph/speexdsp/pull/2","diff_url":"https://github.com/xiph/speexdsp/pull/2.diff","patch_url":"https://github.com/xiph/speexdsp/pull/2.patch","issue_url":"https://api.github.com/repos/xiph/speexdsp/issues/2","number":2,"state":"open","locked":false,"title":"Handle memory allocation failures, and reduce overflow","user":{"login":"jyavenard","id":505748,"avatar_url":"https://avatars.githubusercontent.com/u/505748?v=3","gravatar_id":"","url":"https://api.github.com/users/jyavenard","html_url":"https://github.com/jyavenard","followers_url":"https://api.github.com/users/jyavenard/followers","following_url":"https://api.github.com/users/jyavenard/following{/other_user}","gists_url":"https://api.github.com/users/jyavenard/gists{/gist_id}","starred_url":"https://api.github.com/users/jyavenard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jyavenard/subscriptions","organizations_url":"https://api.github.com/users/jyavenard/orgs","repos_url":"https://api.github.com/users/jyavenard/repos","events_url":"https://api.github.com/users/jyavenard/events{/privacy}","received_events_url":"https://api.github.com/users/jyavenard/received_events","type":"User","site_admin":false},"body":"r? @tmatth\r\n","created_at":"2016-05-07T12:10:44Z","updated_at":"2016-05-08T11:05:45Z","closed_at":null,"merged_at":null,"merge_commit_sha":"669c5cfc28d8b49262f771a5fc483df44ea25cea","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/xiph/speexdsp/pulls/2/commits","review_comments_url":"https://api.github.com/repos/xiph/speexdsp/pulls/2/comments","review_comment_url":"https://api.github.com/repos/xiph/speexdsp/pulls/comments{/number}","comments_url":"https://api.github.com/repos/xiph/speexdsp/issues/2/comments","statuses_url":"https://api.github.com/repos/xiph/speexdsp/statuses/9b2240c36ea5e1c42ae5602cff427b9c40cdd3f5","head":{"label":"jyavenard:master","ref":"master","sha":"9b2240c36ea5e1c42ae5602cff427b9c40cdd3f5","user":{"login":"jyavenard","id":505748,"avatar_url":"https://avatars.githubusercontent.com/u/505748?v=3","gravatar_id":"","url":"https://api.github.com/users/jyavenard","html_url":"https://github.com/jyavenard","followers_url":"https://api.github.com/users/jyavenard/followers","following_url":"https://api.github.com/users/jyavenard/following{/other_user}","gists_url":"https://api.github.com/users/jyavenard/gists{/gist_id}","starred_url":"https://api.github.com/users/jyavenard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jyavenard/subscriptions","organizations_url":"https://api.github.com/users/jyavenard/orgs","repos_url":"https://api.github.com/users/jyavenard/repos","events_url":"https://api.github.com/users/jyavenard/events{/privacy}","received_events_url":"https://api.github.com/users/jyavenard/received_events","type":"User","site_admin":false},"repo":{"id":56556299,"name":"speexdsp","full_name":"jyavenard/speexdsp","owner":{"login":"jyavenard","id":505748,"avatar_url":"https://avatars.githubusercontent.com/u/505748?v=3","gravatar_id":"","url":"https://api.github.com/users/jyavenard","html_url":"https://github.com/jyavenard","followers_url":"https://api.github.com/users/jyavenard/followers","following_url":"https://api.github.com/users/jyavenard/following{/other_user}","gists_url":"https://api.github.com/users/jyavenard/gists{/gist_id}","starred_url":"https://api.github.com/users/jyavenard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jyavenard/subscriptions","organizations_url":"https://api.github.com/users/jyavenard/orgs","repos_url":"https://api.github.com/users/jyavenard/repos","events_url":"https://api.github.com/users/jyavenard/events{/privacy}","received_events_url":"https://api.github.com/users/jyavenard/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jyavenard/speexdsp","description":"Speex audio processing library","fork":true,"url":"https://api.github.com/repos/jyavenard/speexdsp","forks_url":"https://api.github.com/repos/jyavenard/speexdsp/forks","keys_url":"https://api.github.com/repos/jyavenard/speexdsp/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jyavenard/speexdsp/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jyavenard/speexdsp/teams","hooks_url":"https://api.github.com/repos/jyavenard/speexdsp/hooks","issue_events_url":"https://api.github.com/repos/jyavenard/speexdsp/issues/events{/number}","events_url":"https://api.github.com/repos/jyavenard/speexdsp/events","assignees_url":"https://api.github.com/repos/jyavenard/speexdsp/assignees{/user}","branches_url":"https://api.github.com/repos/jyavenard/speexdsp/branches{/branch}","tags_url":"https://api.github.com/repos/jyavenard/speexdsp/tags","blobs_url":"https://api.github.com/repos/jyavenard/speexdsp/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jyavenard/speexdsp/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jyavenard/speexdsp/git/refs{/sha}","trees_url":"https://api.github.com/repos/jyavenard/speexdsp/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jyavenard/speexdsp/statuses/{sha}","languages_url":"https://api.github.com/repos/jyavenard/speexdsp/languages","stargazers_url":"https://api.github.com/repos/jyavenard/speexdsp/stargazers","contributors_url":"https://api.github.com/repos/jyavenard/speexdsp/contributors","subscribers_url":"https://api.github.com/repos/jyavenard/speexdsp/subscribers","subscription_url":"https://api.github.com/repos/jyavenard/speexdsp/subscription","commits_url":"https://api.github.com/repos/jyavenard/speexdsp/commits{/sha}","git_commits_url":"https://api.github.com/repos/jyavenard/speexdsp/git/commits{/sha}","comments_url":"https://api.github.com/repos/jyavenard/speexdsp/comments{/number}","issue_comment_url":"https://api.github.com/repos/jyavenard/speexdsp/issues/comments{/number}","contents_url":"https://api.github.com/repos/jyavenard/speexdsp/contents/{+path}","compare_url":"https://api.github.com/repos/jyavenard/speexdsp/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jyavenard/speexdsp/merges","archive_url":"https://api.github.com/repos/jyavenard/speexdsp/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jyavenard/speexdsp/downloads","issues_url":"https://api.github.com/repos/jyavenard/speexdsp/issues{/number}","pulls_url":"https://api.github.com/repos/jyavenard/speexdsp/pulls{/number}","milestones_url":"https://api.github.com/repos/jyavenard/speexdsp/milestones{/number}","notifications_url":"https://api.github.com/repos/jyavenard/speexdsp/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jyavenard/speexdsp/labels{/name}","releases_url":"https://api.github.com/repos/jyavenard/speexdsp/releases{/id}","deployments_url":"https://api.github.com/repos/jyavenard/speexdsp/deployments","created_at":"2016-04-19T01:57:00Z","updated_at":"2016-04-19T01:57:03Z","pushed_at":"2016-05-07T12:09:44Z","git_url":"git://github.com/jyavenard/speexdsp.git","ssh_url":"git@github.com:jyavenard/speexdsp.git","clone_url":"https://github.com/jyavenard/speexdsp.git","svn_url":"https://github.com/jyavenard/speexdsp","homepage":"","size":5829,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"xiph:master","ref":"master","sha":"13d02a0f66e25c7fbcfbb833ec534251e4ab59db","user":{"login":"xiph","id":8365509,"avatar_url":"https://avatars.githubusercontent.com/u/8365509?v=3","gravatar_id":"","url":"https://api.github.com/users/xiph","html_url":"https://github.com/xiph","followers_url":"https://api.github.com/users/xiph/followers","following_url":"https://api.github.com/users/xiph/following{/other_user}","gists_url":"https://api.github.com/users/xiph/gists{/gist_id}","starred_url":"https://api.github.com/users/xiph/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xiph/subscriptions","organizations_url":"https://api.github.com/users/xiph/orgs","repos_url":"https://api.github.com/users/xiph/repos","events_url":"https://api.github.com/users/xiph/events{/privacy}","received_events_url":"https://api.github.com/users/xiph/received_events","type":"Organization","site_admin":false},"repo":{"id":27654102,"name":"speexdsp","full_name":"xiph/speexdsp","owner":{"login":"xiph","id":8365509,"avatar_url":"https://avatars.githubusercontent.com/u/8365509?v=3","gravatar_id":"","url":"https://api.github.com/users/xiph","html_url":"https://github.com/xiph","followers_url":"https://api.github.com/users/xiph/followers","following_url":"https://api.github.com/users/xiph/following{/other_user}","gists_url":"https://api.github.com/users/xiph/gists{/gist_id}","starred_url":"https://api.github.com/users/xiph/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xiph/subscriptions","organizations_url":"https://api.github.com/users/xiph/orgs","repos_url":"https://api.github.com/users/xiph/repos","events_url":"https://api.github.com/users/xiph/events{/privacy}","received_events_url":"https://api.github.com/users/xiph/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/xiph/speexdsp","description":"Speex audio processing library","fork":false,"url":"https://api.github.com/repos/xiph/speexdsp","forks_url":"https://api.github.com/repos/xiph/speexdsp/forks","keys_url":"https://api.github.com/repos/xiph/speexdsp/keys{/key_id}","collaborators_url":"https://api.github.com/repos/xiph/speexdsp/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/xiph/speexdsp/teams","hooks_url":"https://api.github.com/repos/xiph/speexdsp/hooks","issue_events_url":"https://api.github.com/repos/xiph/speexdsp/issues/events{/number}","events_url":"https://api.github.com/repos/xiph/speexdsp/events","assignees_url":"https://api.github.com/repos/xiph/speexdsp/assignees{/user}","branches_url":"https://api.github.com/repos/xiph/speexdsp/branches{/branch}","tags_url":"https://api.github.com/repos/xiph/speexdsp/tags","blobs_url":"https://api.github.com/repos/xiph/speexdsp/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/xiph/speexdsp/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/xiph/speexdsp/git/refs{/sha}","trees_url":"https://api.github.com/repos/xiph/speexdsp/git/trees{/sha}","statuses_url":"https://api.github.com/repos/xiph/speexdsp/statuses/{sha}","languages_url":"https://api.github.com/repos/xiph/speexdsp/languages","stargazers_url":"https://api.github.com/repos/xiph/speexdsp/stargazers","contributors_url":"https://api.github.com/repos/xiph/speexdsp/contributors","subscribers_url":"https://api.github.com/repos/xiph/speexdsp/subscribers","subscription_url":"https://api.github.com/repos/xiph/speexdsp/subscription","commits_url":"https://api.github.com/repos/xiph/speexdsp/commits{/sha}","git_commits_url":"https://api.github.com/repos/xiph/speexdsp/git/commits{/sha}","comments_url":"https://api.github.com/repos/xiph/speexdsp/comments{/number}","issue_comment_url":"https://api.github.com/repos/xiph/speexdsp/issues/comments{/number}","contents_url":"https://api.github.com/repos/xiph/speexdsp/contents/{+path}","compare_url":"https://api.github.com/repos/xiph/speexdsp/compare/{base}...{head}","merges_url":"https://api.github.com/repos/xiph/speexdsp/merges","archive_url":"https://api.github.com/repos/xiph/speexdsp/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/xiph/speexdsp/downloads","issues_url":"https://api.github.com/repos/xiph/speexdsp/issues{/number}","pulls_url":"https://api.github.com/repos/xiph/speexdsp/pulls{/number}","milestones_url":"https://api.github.com/repos/xiph/speexdsp/milestones{/number}","notifications_url":"https://api.github.com/repos/xiph/speexdsp/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/xiph/speexdsp/labels{/name}","releases_url":"https://api.github.com/repos/xiph/speexdsp/releases{/id}","deployments_url":"https://api.github.com/repos/xiph/speexdsp/deployments","created_at":"2014-12-07T00:23:23Z","updated_at":"2016-05-06T04:20:49Z","pushed_at":"2016-05-07T12:10:44Z","git_url":"git://github.com/xiph/speexdsp.git","ssh_url":"git@github.com:xiph/speexdsp.git","clone_url":"https://github.com/xiph/speexdsp.git","svn_url":"https://github.com/xiph/speexdsp","homepage":"","size":6645,"stargazers_count":10,"watchers_count":10,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":10,"mirror_url":null,"open_issues_count":1,"forks":10,"open_issues":1,"watchers":10,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/xiph/speexdsp/pulls/2"},"html":{"href":"https://github.com/xiph/speexdsp/pull/2"},"issue":{"href":"https://api.github.com/repos/xiph/speexdsp/issues/2"},"comments":{"href":"https://api.github.com/repos/xiph/speexdsp/issues/2/comments"},"review_comments":{"href":"https://api.github.com/repos/xiph/speexdsp/pulls/2/comments"},"review_comment":{"href":"https://api.github.com/repos/xiph/speexdsp/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/xiph/speexdsp/pulls/2/commits"},"statuses":{"href":"https://api.github.com/repos/xiph/speexdsp/statuses/9b2240c36ea5e1c42ae5602cff427b9c40cdd3f5"}}}}