• L
    qapi-commands.py: Don't call the output marshal on error · 694a099a
    Luiz Capitulino 提交于
    Today we generate something like this:
    
        int qmp_marshal_input_query_foo(...)
    
            ...
    
            retval = qmp_query_foo(errp);
            qmp_marshal_output_query_foo(retval, ret, errp);
    
            ...
    
    However, if qmp_query_foo() fails 'retval' will probably be NULL,
    which can cause a segfault as not all visitors check if 'retval'
    is valid.
    
    This commit fixes that by changing the code generator to only
    call the output marshal if qmp_query_foo() succeeds, like this:
    
        retval = qmp_query_foo(errp);
        if (!error_is_set(errp)) {
            qmp_marshal_output_query_foo(retval, ret, errp);
        }
    Signed-off-by: NLuiz Capitulino <lcapitulino@redhat.com>
    694a099a
qapi-commands.py 10.9 KB