]> xenbits.xensource.com Git - libvirt.git/commitdiff
virNetServerProgramDispatchCall: Avoid calling xdr_free(_, NULL)
authorMichal Privoznik <mprivozn@redhat.com>
Fri, 7 Oct 2022 11:05:03 +0000 (13:05 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Fri, 7 Oct 2022 15:15:49 +0000 (17:15 +0200)
In recent commit of v8.8.0-41-g41eb0f446c I've suggested during
review to put both xdr_free() calls under error label, assuming
that xdr_free() accepts NULL and thus is a NOP when the control
jumps onto the label even before either of @arg or @ret was
allocated. Well, turns out, xdr_free() does no accept NULL and
thus we have to guard its call. But since @dispatcher is already
set by the time either of the variables is allocated, we can
replace the condition from 'if (dispatcher)' to 'if (arg)' and
'if (ret)'.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
src/rpc/virnetserverprogram.c

index 212e0d5ab52b941437873137664e97d2035f76e9..58b6a278ca111b020e43eb36527029ffaa7b050b 100644 (file)
@@ -475,10 +475,10 @@ virNetServerProgramDispatchCall(virNetServerProgram *prog,
     return virNetServerClientSendMessage(client, msg);
 
  error:
-    if (dispatcher) {
+    if (arg)
         xdr_free(dispatcher->arg_filter, arg);
+    if (ret)
         xdr_free(dispatcher->ret_filter, ret);
-    }
 
     /* Bad stuff (de-)serializing message, but we have an
      * RPC error message we can send back to the client */