{"action":"opened","issue":{"url":"https://api.github.com/repos/libgd/libgd/issues/21","labels_url":"https://api.github.com/repos/libgd/libgd/issues/21/labels{/name}","comments_url":"https://api.github.com/repos/libgd/libgd/issues/21/comments","events_url":"https://api.github.com/repos/libgd/libgd/issues/21/events","html_url":"https://github.com/libgd/libgd/issues/21","id":56608052,"number":21,"title":"gdImageFilledRectangle can take very long time with rects outside of image","user":{"login":"imazen-bot","id":10421256,"avatar_url":"https://avatars.githubusercontent.com/u/10421256?v=3","gravatar_id":"","url":"https://api.github.com/users/imazen-bot","html_url":"https://github.com/imazen-bot","followers_url":"https://api.github.com/users/imazen-bot/followers","following_url":"https://api.github.com/users/imazen-bot/following{/other_user}","gists_url":"https://api.github.com/users/imazen-bot/gists{/gist_id}","starred_url":"https://api.github.com/users/imazen-bot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/imazen-bot/subscriptions","organizations_url":"https://api.github.com/users/imazen-bot/orgs","repos_url":"https://api.github.com/users/imazen-bot/repos","events_url":"https://api.github.com/users/imazen-bot/events{/privacy}","received_events_url":"https://api.github.com/users/imazen-bot/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-02-05T00:07:57Z","updated_at":"2015-02-05T00:07:57Z","closed_at":null,"body":"There is an (arguable) bug in gdImageFilledRectangle:\n\nIf you call it with a rect outside of the image bounds it may take surprisingly long depending on the position. The user would expect that the performance does not depent on the position of the rect.\n\nConsider the arguments: x1=-2147483648, y1=57, x2=-2147483644, y2=65\nThe function clips x1 and y2 to the image, but not x2 and y2. This sets the parameters to\nx1=0, y1=57, x2=-2147483644, y2=65\nThen it swaps x1/x2 if needed, setting to parameters to\nx1=-2147483644, y1=57, x2=0, y2=65\nThis leads to an iteration from -2147483644 to 0.\n\nClipping needs to be done on x2 and y2 also in \"gd.c\" line 2400ff.\n\n----------------------------------------\n- Bitbucket: https://bitbucket.org/libgd/gd-libgd/issue/21\n- Originally reported by: [GabrielSchreiber (Gabriel Schreiber)](http://bitbucket.org/GabrielSchreiber)\n- Originally created on: Aug 21 2012\n"}}