Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
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-winehq
Commits
a5d56993
Commit
a5d56993
authored
Nov 06, 2014
by
Vincent Povirk
Committed by
Alexandre Julliard
Nov 07, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
windowscodecs: Fix race condition loading libpng.
parent
48c36db4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
4 deletions
+24
-4
pngformat.c
dlls/windowscodecs/pngformat.c
+24
-4
No files found.
dlls/windowscodecs/pngformat.c
View file @
a5d56993
...
...
@@ -200,13 +200,28 @@ MAKE_FUNCPTR(png_write_info);
MAKE_FUNCPTR
(
png_write_rows
);
#undef MAKE_FUNCPTR
static
CRITICAL_SECTION
init_png_cs
;
static
CRITICAL_SECTION_DEBUG
init_png_cs_debug
=
{
0
,
0
,
&
init_png_cs
,
{
&
init_png_cs_debug
.
ProcessLocksList
,
&
init_png_cs_debug
.
ProcessLocksList
},
0
,
0
,
{
(
DWORD_PTR
)(
__FILE__
": init_png_cs"
)
}
};
static
CRITICAL_SECTION
init_png_cs
=
{
&
init_png_cs_debug
,
-
1
,
0
,
0
,
0
,
0
};
static
void
*
load_libpng
(
void
)
{
if
((
libpng_handle
=
wine_dlopen
(
SONAME_LIBPNG
,
RTLD_NOW
,
NULL
,
0
))
!=
NULL
)
{
void
*
result
;
EnterCriticalSection
(
&
init_png_cs
);
if
(
!
libpng_handle
&&
(
libpng_handle
=
wine_dlopen
(
SONAME_LIBPNG
,
RTLD_NOW
,
NULL
,
0
))
!=
NULL
)
{
#define LOAD_FUNCPTR(f) \
if((p##f = wine_dlsym(libpng_handle, #f, NULL, 0)) == NULL) { \
libpng_handle = NULL; \
LeaveCriticalSection(&init_png_cs); \
return NULL; \
}
LOAD_FUNCPTR
(
png_create_read_struct
);
...
...
@@ -251,7 +266,12 @@ static void *load_libpng(void)
#undef LOAD_FUNCPTR
}
return
libpng_handle
;
result
=
libpng_handle
;
LeaveCriticalSection
(
&
init_png_cs
);
return
result
;
}
static
void
user_error_fn
(
png_structp
png_ptr
,
png_const_charp
error_message
)
...
...
@@ -997,7 +1017,7 @@ HRESULT PngDecoder_CreateInstance(REFIID iid, void** ppv)
*
ppv
=
NULL
;
if
(
!
l
ibpng_handle
&&
!
l
oad_libpng
())
if
(
!
load_libpng
())
{
ERR
(
"Failed reading PNG because unable to find %s
\n
"
,
SONAME_LIBPNG
);
return
E_FAIL
;
...
...
@@ -1726,7 +1746,7 @@ HRESULT PngEncoder_CreateInstance(REFIID iid, void** ppv)
*
ppv
=
NULL
;
if
(
!
l
ibpng_handle
&&
!
l
oad_libpng
())
if
(
!
load_libpng
())
{
ERR
(
"Failed writing PNG because unable to find %s
\n
"
,
SONAME_LIBPNG
);
return
E_FAIL
;
...
...
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