qapi: Avoid output visitor crashing if it encounters a NULL value
A NULL value is not added to visitor's stack, but there is no check for that when the visitor tries to return that value, leading to QEMU crash. Reviewed-by: Eric Blake <eblake@redhat.com> Acked-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Marcel Apfelbaum <marcel.a@redhat.com> Acked-by: Michael S. Tsirkin <mst@redhat.com> Acked-by: Michael Roth <mdroth@linux.vnet.ibm.com> Signed-off-by: Andreas Färber <afaerber@suse.de>
This commit is contained in:
		
							parent
							
								
									13d7adf92a
								
							
						
					
					
						commit
						1d10b44546
					
				| 
						 | 
				
			
			@ -66,6 +66,12 @@ static QObject *qmp_output_pop(QmpOutputVisitor *qov)
 | 
			
		|||
static QObject *qmp_output_first(QmpOutputVisitor *qov)
 | 
			
		||||
{
 | 
			
		||||
    QStackEntry *e = QTAILQ_LAST(&qov->stack, QStack);
 | 
			
		||||
 | 
			
		||||
    /* FIXME - find a better way to deal with NULL values */
 | 
			
		||||
    if (!e) {
 | 
			
		||||
        return NULL;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return e->value;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue