this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Added NULL test to version_string so renderer init can fail more gracefully when the context is not created right. Also added a missing test for NULL context gotten from SDL so init should fail early instead of getting to version_string. Fixed CopySurfaceFromImage() for when result->pitch is smaller than source_pitch.

+15 -4
+15 -4
src/renderer_GL_common.inl
··· 1096 1096 #ifdef SDL_GPU_USE_OPENGL 1097 1097 // OpenGL < 3.0 doesn't have GL_MAJOR_VERSION. Check via version string instead. 1098 1098 version_string = (const char*)glGetString(GL_VERSION); 1099 - if(sscanf(version_string, "%d.%d", major, minor) <= 0) 1099 + if(version_string == NULL || sscanf(version_string, "%d.%d", major, minor) <= 0) 1100 1100 { 1101 1101 // Failure 1102 1102 *major = SDL_GPU_GL_MAJOR_VERSION; ··· 1114 1114 // GLES doesn't have GL_MAJOR_VERSION. Check via version string instead. 1115 1115 version_string = (const char*)glGetString(GL_VERSION); 1116 1116 // OpenGL ES 2.0? 1117 - if(sscanf(version_string, "OpenGL ES %d.%d", major, minor) <= 0) 1117 + if(version_string == NULL || sscanf(version_string, "OpenGL ES %d.%d", major, minor) <= 0) 1118 1118 { 1119 1119 // OpenGL ES-CM 1.1? OpenGL ES-CL 1.1? 1120 - if(sscanf(version_string, "OpenGL ES-C%*c %d.%d", major, minor) <= 0) 1120 + if(version_string == NULL || sscanf(version_string, "OpenGL ES-C%*c %d.%d", major, minor) <= 0) 1121 1121 { 1122 1122 // Failure 1123 1123 *major = SDL_GPU_GLES_MAJOR_VERSION; ··· 1272 1272 if(created || target->context->context == NULL) 1273 1273 { 1274 1274 target->context->context = SDL_GL_CreateContext(window); 1275 + if(target->context->context == NULL) 1276 + { 1277 + GPU_PushErrorCode("GPU_CreateTargetFromWindow", GPU_ERROR_BACKEND_ERROR, "Failed to create GL context."); 1278 + SDL_free(cdata->blit_buffer); 1279 + SDL_free(cdata->index_buffer); 1280 + SDL_free(target->context->data); 1281 + SDL_free(target->context); 1282 + SDL_free(target->data); 1283 + SDL_free(target); 1284 + return NULL; 1285 + } 1275 1286 GPU_AddWindowMapping(target); 1276 1287 } 1277 1288 ··· 2544 2555 int source_pitch = image->texture_w*format->BytesPerPixel; // Use the actual texture width to pull from the data 2545 2556 for(i = 0; i < h; ++i) 2546 2557 { 2547 - memcpy((Uint8*)result->pixels + i*result->pitch, data + source_pitch*i, source_pitch); 2558 + memcpy((Uint8*)result->pixels + i*result->pitch, data + source_pitch*i, result->pitch); 2548 2559 } 2549 2560 } 2550 2561