{"action":"opened","issue":{"url":"https://api.github.com/repos/Andrettin/Wyrmgus/issues/28","labels_url":"https://api.github.com/repos/Andrettin/Wyrmgus/issues/28/labels{/name}","comments_url":"https://api.github.com/repos/Andrettin/Wyrmgus/issues/28/comments","events_url":"https://api.github.com/repos/Andrettin/Wyrmgus/issues/28/events","html_url":"https://github.com/Andrettin/Wyrmgus/issues/28","id":86948843,"number":28,"title":"Using CGraphic::Flip() on a 32-bit image causes a crash","user":{"login":"Andrettin","id":6322423,"avatar_url":"https://avatars.githubusercontent.com/u/6322423?v=3","gravatar_id":"","url":"https://api.github.com/users/Andrettin","html_url":"https://github.com/Andrettin","followers_url":"https://api.github.com/users/Andrettin/followers","following_url":"https://api.github.com/users/Andrettin/following{/other_user}","gists_url":"https://api.github.com/users/Andrettin/gists{/gist_id}","starred_url":"https://api.github.com/users/Andrettin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Andrettin/subscriptions","organizations_url":"https://api.github.com/users/Andrettin/orgs","repos_url":"https://api.github.com/users/Andrettin/repos","events_url":"https://api.github.com/users/Andrettin/events{/privacy}","received_events_url":"https://api.github.com/users/Andrettin/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-06-10T12:13:30Z","updated_at":"2015-06-10T12:13:30Z","closed_at":null,"body":"Something is amiss with this piece of code in CGraphic::Flip(), which is causing a crash when the function is used on a 32-bit image:\r\n\r\n´´´\r\n  case 4: {\r\n   unsigned int p0 = s->pitch;\r\n   unsigned int p1 = Surface->pitch;\r\n   const int width = s->w;\r\n   int j = 0;\r\n   for (int i = 0; i < s->h; ++i) {\r\n#ifdef _MSC_VER\r\n    for (j = 0; j < width; ++j) {\r\n     *(Uint32 *)&((char *)s->pixels)[j * 4 + p0] =\r\n      *(Uint32 *) & ((char *)Surface->pixels)[(width - j - 1) * 4 + p1];\r\n    }\r\n#else\r\n    int n = (width + 7) / 8;\r\n    switch (width & 7) {\r\n     case 0: do {\r\n       *(Uint32 *)&((char *)s->pixels)[j * 4 + p0] =\r\n        *(Uint32 *) & ((char *)Surface->pixels)[(width - j - 1) * 4 + p1];\r\n       j++;\r\n      case 7:\r\n       *(Uint32 *)&((char *)s->pixels)[j * 4 + p0] =\r\n        *(Uint32 *) & ((char *)Surface->pixels)[(width - j - 1) * 4 + p1];\r\n       j++;\r\n      case 6:\r\n       *(Uint32 *)&((char *)s->pixels)[j * 4 + p0] =\r\n        *(Uint32 *) & ((char *)Surface->pixels)[(width - j - 1) * 4 + p1];\r\n       j++;\r\n      case 5:\r\n       *(Uint32 *)&((char *)s->pixels)[j * 4 + p0] =\r\n        *(Uint32 *) & ((char *)Surface->pixels)[(width - j - 1) * 4 + p1];\r\n       j++;\r\n      case 4:\r\n       *(Uint32 *)&((char *)s->pixels)[j * 4 + p0] =\r\n        *(Uint32 *) & ((char *)Surface->pixels)[(width - j - 1) * 4 + p1];\r\n       j++;\r\n      case 3:\r\n       *(Uint32 *)&((char *)s->pixels)[j * 4 + p0] =\r\n        *(Uint32 *) & ((char *)Surface->pixels)[(width - j - 1) * 4 + p1];\r\n       j++;\r\n      case 2:\r\n       *(Uint32 *)&((char *)s->pixels)[j * 4 + p0] =\r\n        *(Uint32 *) & ((char *)Surface->pixels)[(width - j - 1) * 4 + p1];\r\n       j++;\r\n      case 1:\r\n       *(Uint32 *)&((char *)s->pixels)[j * 4 + p0] =\r\n        *(Uint32 *) & ((char *)Surface->pixels)[(width - j - 1) * 4 + p1];\r\n       j++;\r\n      } while (--n > 0);\r\n    }\r\n#endif\r\n    p0 += s->pitch;\r\n    p1 += Surface->pitch;\r\n   }\r\n  }\r\n  break;\r\n´´´"}}