{"action":"closed","issue":{"url":"https://api.github.com/repos/adafruit/Adafruit_DotStar_Pi/issues/4","labels_url":"https://api.github.com/repos/adafruit/Adafruit_DotStar_Pi/issues/4/labels{/name}","comments_url":"https://api.github.com/repos/adafruit/Adafruit_DotStar_Pi/issues/4/comments","events_url":"https://api.github.com/repos/adafruit/Adafruit_DotStar_Pi/issues/4/events","html_url":"https://github.com/adafruit/Adafruit_DotStar_Pi/issues/4","id":59480719,"number":4,"title":"Possible bug in dotstar.c pointer arithmetic","user":{"login":"dtiller","id":3858971,"avatar_url":"https://avatars.githubusercontent.com/u/3858971?v=3","gravatar_id":"","url":"https://api.github.com/users/dtiller","html_url":"https://github.com/dtiller","followers_url":"https://api.github.com/users/dtiller/followers","following_url":"https://api.github.com/users/dtiller/following{/other_user}","gists_url":"https://api.github.com/users/dtiller/gists{/gist_id}","starred_url":"https://api.github.com/users/dtiller/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dtiller/subscriptions","organizations_url":"https://api.github.com/users/dtiller/orgs","repos_url":"https://api.github.com/users/dtiller/repos","events_url":"https://api.github.com/users/dtiller/events{/privacy}","received_events_url":"https://api.github.com/users/dtiller/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-03-02T13:26:50Z","updated_at":"2015-03-02T15:38:34Z","closed_at":"2015-03-02T15:38:34Z","body":"On line 349 or so, the LED index is checked against numLEDs, but it does not protect against negative numbers. The demo python script 'strandtest.py' that you supply explicitly calls this function with negative LED indices for variable 'i', which probably leads to some interesting (and out of bounds) pointer arithmetic on this line:\r\n\r\nuint8_t *ptr = &self->pixels[i * 4 + 1];\r\n\r\nHere's a patch.\r\n\r\n349c349\r\n<       if(i < self->numLEDs) {\r\n---\r\n>       if(i >=0 && i < self->numLEDs) {\r\n\r\n"}}