__glXDRIscreenCreateContext: free context on failure, instead of leaking it
Reported with other leaks found by cppcheck in bugzilla #50281 https://bugs.freedesktop.org/show_bug.cgi?id=50281 Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
This commit is contained in:
		
							parent
							
								
									7ab98bafc9
								
							
						
					
					
						commit
						9567fa9a72
					
				| 
						 | 
					@ -645,8 +645,10 @@ __glXDRIscreenCreateContext(__GLXscreen * baseScreen,
 | 
				
			||||||
    for (i = 0; i < pScreen->numVisuals; i++, visual++)
 | 
					    for (i = 0; i < pScreen->numVisuals; i++, visual++)
 | 
				
			||||||
        if (visual->vid == glxConfig->visualID)
 | 
					        if (visual->vid == glxConfig->visualID)
 | 
				
			||||||
            break;
 | 
					            break;
 | 
				
			||||||
    if (i == pScreen->numVisuals)
 | 
					    if (i == pScreen->numVisuals) {
 | 
				
			||||||
 | 
					        free(context);
 | 
				
			||||||
        return NULL;
 | 
					        return NULL;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    context->hwContextID = FakeClientID(0);
 | 
					    context->hwContextID = FakeClientID(0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -655,8 +657,10 @@ __glXDRIscreenCreateContext(__GLXscreen * baseScreen,
 | 
				
			||||||
                              context->hwContextID, &hwContext);
 | 
					                              context->hwContextID, &hwContext);
 | 
				
			||||||
    __glXleaveServer(GL_FALSE);
 | 
					    __glXleaveServer(GL_FALSE);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (!retval)
 | 
					    if (!retval) {
 | 
				
			||||||
 | 
					        free(context);
 | 
				
			||||||
        return NULL;
 | 
					        return NULL;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    context->driContext = screen->legacy->createNewContext(screen->driScreen, config->driConfig, 0,     /* render type */
 | 
					    context->driContext = screen->legacy->createNewContext(screen->driScreen, config->driConfig, 0,     /* render type */
 | 
				
			||||||
                                                           driShare,
 | 
					                                                           driShare,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue