@@ -338,7 +338,6 @@ int Socs::soc_num_inits() {
338338}
339339
340340bool Socs::isSnapDragon (const char *manufacturer) {
341- soc_info_init ();
342341#ifdef __ANDROID__
343342 bool is_qcom = false ;
344343 if (strncmp (" QUALCOMM" , manufacturer, 7 ) == 0 ) {
@@ -357,14 +356,38 @@ bool Socs::isSnapDragon(const char *manufacturer) {
357356
358357 /* get an EGL display connection */
359358 display = eglGetDisplay (EGL_DEFAULT_DISPLAY);
359+ if (display == EGL_NO_DISPLAY) {
360+ LOG (ERROR) << " Failed to get EGL display" ;
361+ return false ;
362+ }
360363 /* initialize the EGL display connection */
361- eglInitialize (display, NULL , NULL );
364+ if (eglInitialize (display, NULL , NULL ) == EGL_FALSE) {
365+ LOG (ERROR) << " Failed to initialize EGL" ;
366+ eglTerminate (display);
367+ return false ;
368+ }
362369 /* get an appropriate EGL frame buffer configuration */
363- eglChooseConfig (display, attribute_list, &config, 1 , &num_config);
370+ if (eglChooseConfig (display, attribute_list, &config, 1 , &num_config) == EGL_FALSE || num_config == 0 ) {
371+ LOG (ERROR) << " Failed to choose EGL config" ;
372+ eglTerminate (display);
373+ return false ;
374+ }
364375 /* create an EGL rendering context */
365376 context = eglCreateContext (display, config, EGL_NO_CONTEXT, NULL );
377+ if (context == EGL_NO_CONTEXT) {
378+ LOG (ERROR) << " Failed to create EGL context" ;
379+ eglDestroySurface (display, surface);
380+ eglTerminate (display);
381+ return false ;
382+ }
366383 /* connect the context to the surface */
367- eglMakeCurrent (display, EGL_NO_SURFACE, EGL_NO_SURFACE, context);
384+ if (eglMakeCurrent (display, EGL_NO_SURFACE, EGL_NO_SURFACE, context) == EGL_FALSE) {
385+ LOG (ERROR) << " Failed to make EGL context current" ;
386+ eglDestroyContext (display, context);
387+ eglDestroySurface (display, surface);
388+ eglTerminate (display);
389+ return false ;
390+ }
368391
369392 const unsigned char *vendor = glGetString (GL_VENDOR);
370393
0 commit comments