Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
4768ac44
Commit
4768ac44
authored
Mar 25, 2014
by
Nikolay Sivov
Committed by
Alexandre Julliard
Mar 25, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ole32: Fix leaks on error paths (Coverity).
parent
43b5f46f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
66 additions
and
66 deletions
+66
-66
filemoniker.c
dlls/ole32/filemoniker.c
+66
-66
No files found.
dlls/ole32/filemoniker.c
View file @
4768ac44
...
...
@@ -935,11 +935,12 @@ static HRESULT WINAPI
FileMonikerImpl_CommonPrefixWith
(
IMoniker
*
iface
,
IMoniker
*
pmkOther
,
IMoniker
**
ppmkPrefix
)
{
LPOLESTR
pathThis
,
pathOther
,
*
stringTable1
,
*
stringTable2
,
commonPath
;
IBindCtx
*
pbind
;
LPOLESTR
pathThis
=
NULL
,
pathOther
=
NULL
,
*
stringTable1
,
*
stringTable2
,
commonPath
=
NULL
;
IBindCtx
*
bindctx
;
DWORD
mkSys
;
ULONG
nb1
,
nb2
,
i
,
sameIdx
;
BOOL
machineNameCase
=
FALSE
;
HRESULT
ret
;
if
(
ppmkPrefix
==
NULL
)
return
E_POINTER
;
...
...
@@ -951,81 +952,81 @@ FileMonikerImpl_CommonPrefixWith(IMoniker* iface,IMoniker* pmkOther,IMoniker** p
/* check if we have the same type of moniker */
IMoniker_IsSystemMoniker
(
pmkOther
,
&
mkSys
);
if
(
mkSys
!=
MKSYS_FILEMONIKER
)
return
MonikerCommonPrefixWith
(
iface
,
pmkOther
,
ppmkPrefix
);
if
(
mkSys
==
MKSYS_FILEMONIKER
){
HRESULT
ret
;
ret
=
CreateBindCtx
(
0
,
&
pbind
);
if
(
FAILED
(
ret
))
return
ret
;
/* create a string based on common part of the two paths */
ret
=
IMoniker_GetDisplayName
(
iface
,
pbind
,
NULL
,
&
pathThis
);
if
(
FAILED
(
ret
))
return
ret
;
ret
=
IMoniker_GetDisplayName
(
pmkOther
,
pbind
,
NULL
,
&
pathOther
);
if
(
FAILED
(
ret
))
return
ret
;
nb1
=
FileMonikerImpl_DecomposePath
(
pathThis
,
&
stringTable1
);
if
(
FAILED
(
nb1
))
return
nb1
;
nb2
=
FileMonikerImpl_DecomposePath
(
pathOther
,
&
stringTable2
);
if
(
FAILED
(
nb2
))
{
free_stringtable
(
stringTable1
);
return
nb2
;
}
if
(
nb1
==
0
||
nb2
==
0
)
{
free_stringtable
(
stringTable1
);
free_stringtable
(
stringTable2
);
return
MK_E_NOPREFIX
;
}
commonPath
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
WCHAR
)
*
(
min
(
lstrlenW
(
pathThis
),
lstrlenW
(
pathOther
))
+
1
));
if
(
!
commonPath
)
return
E_OUTOFMEMORY
;
ret
=
CreateBindCtx
(
0
,
&
bindctx
);
if
(
FAILED
(
ret
))
return
ret
;
*
commonPath
=
0
;
/* create a string based on common part of the two paths */
ret
=
IMoniker_GetDisplayName
(
iface
,
bindctx
,
NULL
,
&
pathThis
);
if
(
FAILED
(
ret
))
goto
failed
;
for
(
sameIdx
=
0
;
(
(
stringTable1
[
sameIdx
]
!=
NULL
)
&&
(
stringTable2
[
sameIdx
]
!=
NULL
)
&&
(
lstrcmpiW
(
stringTable1
[
sameIdx
],
stringTable2
[
sameIdx
])
==
0
));
sameIdx
++
)
;
ret
=
IMoniker_GetDisplayName
(
pmkOther
,
bindctx
,
NULL
,
&
pathOther
);
if
(
FAILED
(
ret
))
goto
failed
;
if
(
sameIdx
>
1
&&
*
stringTable1
[
0
]
==
'\\'
&&
*
stringTable2
[
1
]
==
'\\'
){
nb1
=
FileMonikerImpl_DecomposePath
(
pathThis
,
&
stringTable1
);
if
(
FAILED
(
nb1
))
{
ret
=
nb1
;
goto
failed
;
}
machineNameCase
=
TRUE
;
nb2
=
FileMonikerImpl_DecomposePath
(
pathOther
,
&
stringTable2
);
if
(
FAILED
(
nb2
))
{
ret
=
nb2
;
goto
failed
;
}
for
(
i
=
2
;
i
<
sameIdx
;
i
++
)
if
(
nb1
==
0
||
nb2
==
0
)
{
ret
=
MK_E_NOPREFIX
;
goto
failed
;
}
if
(
(
*
stringTable1
[
i
]
==
'\\'
)
&&
(
i
+
1
<
sameIdx
)
&&
(
*
stringTable1
[
i
+
1
]
==
'\\'
)
){
machineNameCase
=
FALSE
;
break
;
}
}
commonPath
=
CoTaskMemAlloc
(
sizeof
(
WCHAR
)
*
(
min
(
lstrlenW
(
pathThis
),
lstrlenW
(
pathOther
))
+
1
));
if
(
!
commonPath
)
{
ret
=
E_OUTOFMEMORY
;
goto
failed
;
}
if
(
machineNameCase
&&
*
stringTable1
[
sameIdx
-
1
]
==
'\\'
)
sameIdx
--
;
*
commonPath
=
0
;
for
(
sameIdx
=
0
;
(
(
stringTable1
[
sameIdx
]
!=
NULL
)
&&
(
stringTable2
[
sameIdx
]
!=
NULL
)
&&
(
lstrcmpiW
(
stringTable1
[
sameIdx
],
stringTable2
[
sameIdx
])
==
0
));
sameIdx
++
);
if
(
machineNameCase
&&
(
sameIdx
<=
3
)
&&
(
nb1
>
3
||
nb2
>
3
)
)
ret
=
MK_E_NOPREFIX
;
else
{
for
(
i
=
0
;
i
<
sameIdx
;
i
++
)
strcatW
(
commonPath
,
stringTable1
[
i
]);
if
(
sameIdx
>
1
&&
*
stringTable1
[
0
]
==
'\\'
&&
*
stringTable2
[
1
]
==
'\\'
){
machineNameCase
=
TRUE
;
free_stringtable
(
stringTable1
);
free_stringtable
(
stringTable2
);
ret
=
CreateFileMoniker
(
commonPath
,
ppmkPrefix
);
for
(
i
=
2
;
i
<
sameIdx
;
i
++
)
if
(
(
*
stringTable1
[
i
]
==
'\\'
)
&&
(
i
+
1
<
sameIdx
)
&&
(
*
stringTable1
[
i
+
1
]
==
'\\'
)
){
machineNameCase
=
FALSE
;
break
;
}
HeapFree
(
GetProcessHeap
(),
0
,
commonPath
);
return
ret
;
}
if
(
machineNameCase
&&
*
stringTable1
[
sameIdx
-
1
]
==
'\\'
)
sameIdx
--
;
if
(
machineNameCase
&&
(
sameIdx
<=
3
)
&&
(
nb1
>
3
||
nb2
>
3
)
)
ret
=
MK_E_NOPREFIX
;
else
return
MonikerCommonPrefixWith
(
iface
,
pmkOther
,
ppmkPrefix
);
{
for
(
i
=
0
;
i
<
sameIdx
;
i
++
)
strcatW
(
commonPath
,
stringTable1
[
i
]);
ret
=
CreateFileMoniker
(
commonPath
,
ppmkPrefix
);
}
failed:
IBindCtx_Release
(
bindctx
);
CoTaskMemFree
(
pathThis
);
CoTaskMemFree
(
pathOther
);
CoTaskMemFree
(
commonPath
);
free_stringtable
(
stringTable1
);
free_stringtable
(
stringTable2
);
return
ret
;
}
/******************************************************************************
...
...
@@ -1105,8 +1106,7 @@ lend:
CoTaskMemFree
(
strgtable
);
}
if
(
word
)
CoTaskMemFree
(
word
);
CoTaskMemFree
(
word
);
return
ret
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment