[PATCH] ole32: handle MSHLFLAGS_NORMAL correctly (Coverity)

Marcus Meissner marcus at jet.franken.de
Wed May 6 10:14:02 CDT 2015


Hi,

So the tests fail, but the patch is at least to some degree right
and the patch exposes this latent problem.

Introduced by:
commit 611b5acbf8263f14292eaca6be175b557c6a9d35
Author: Alexandre Julliard <julliard at winehq.org>
Date:   Fri Sep 2 11:18:45 2005 +0000

    Authors: Mike Hearn <mh at codeweavers.com>, Robert Shearman <rob at codeweavers.com>
    Change stub manager to track the number of normal marshals instead of
    using the state machine so that multiple marshals of the same object
    and interface work correctly.


Ciao, Marcus

On Wed, May 06, 2015 at 05:08:04PM +0200, Marcus Meissner wrote:
> 731556 Logically dead code
> 
> MSHLFLAGS_NORMAL is 0, so masking it directly will lead to dead code.
> 
> This enum MSHLFLAGS is pretty much misnamed, it seems part
> enum of types and the MSHLFLAGS_NOPING flag.
> 
> It seems like:
> ------ types:
>   MSHLFLAGS_NORMAL      = 0,
>   MSHLFLAGS_TABLESTRONG = 1,
>   MSHLFLAGS_TABLEWEAK   = 2,
> ------ additional flag:
>   MSHLFLAGS_NOPING      = 4
> 
> Ciao, Marcus
> ---
>  dlls/ole32/stubmanager.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/dlls/ole32/stubmanager.c b/dlls/ole32/stubmanager.c
> index fda4944..0769e52 100644
> --- a/dlls/ole32/stubmanager.c
> +++ b/dlls/ole32/stubmanager.c
> @@ -102,7 +102,7 @@ struct ifstub *stub_manager_new_ifstub(struct stub_manager *m, IRpcStubBuffer *s
>      EnterCriticalSection(&m->lock);
>      list_add_head(&m->ifstubs, &stub->entry);
>      /* every normal marshal is counted so we don't allow more than we should */
> -    if (flags & MSHLFLAGS_NORMAL) m->norm_refs++;
> +    if ((flags & (MSHLFLAGS_TABLESTRONG|MSHLFLAGS_TABLEWEAK)) == MSHLFLAGS_NORMAL) m->norm_refs++;
>      LeaveCriticalSection(&m->lock);
>  
>      TRACE("ifstub %p created with ipid %s\n", stub, debugstr_guid(&stub->ipid));
> @@ -548,7 +548,7 @@ BOOL stub_manager_notify_unmarshal(struct stub_manager *m, const IPID *ipid)
>      EnterCriticalSection(&m->lock);
>  
>      /* track normal marshals so we can enforce rules whilst in-process */
> -    if (ifstub->flags & MSHLFLAGS_NORMAL)
> +    if ((ifstub->flags & (MSHLFLAGS_TABLESTRONG|MSHLFLAGS_TABLEWEAK)) == MSHLFLAGS_NORMAL)
>      {
>          if (m->norm_refs)
>              m->norm_refs--;
> -- 
> 1.8.4.5
> 
> 
> 
> 



More information about the wine-patches mailing list