Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
VideoLAN
VLC
Commits
2db583da
Commit
2db583da
authored
Jan 05, 2023
by
Steve Lhomme
Browse files
frame: return early if the win32 HANDLE is not usable
parent
f78a65f0
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/misc/frame.c
View file @
2db583da
...
...
@@ -434,35 +434,32 @@ vlc_frame_t *vlc_frame_File(int fd, bool write)
if
(
length
>
0
)
{
handle
=
(
HANDLE
)(
intptr_t
)
_get_osfhandle
(
fd
);
if
(
handle
!
=
INVALID_HANDLE_VALUE
)
if
(
handle
=
=
INVALID_HANDLE_VALUE
)
{
void
*
addr
=
NULL
;
HANDLE
hMap
;
DWORD
prot
=
write
?
PAGE_READWRITE
:
PAGE_READONLY
;
DWORD
access
=
FILE_MAP_READ
|
(
write
?
FILE_MAP_WRITE
:
0
);
errno
=
EBADF
;
return
NULL
;
}
void
*
addr
=
NULL
;
HANDLE
hMap
;
DWORD
prot
=
write
?
PAGE_READWRITE
:
PAGE_READONLY
;
DWORD
access
=
FILE_MAP_READ
|
(
write
?
FILE_MAP_WRITE
:
0
);
#ifdef VLC_WINSTORE_APP
hMap
=
CreateFileMappingFromApp
(
handle
,
NULL
,
prot
,
length
,
NULL
);
if
(
hMap
!=
INVALID_HANDLE_VALUE
)
addr
=
MapViewOfFileFromApp
(
hMap
,
access
,
0
,
length
);
hMap
=
CreateFileMappingFromApp
(
handle
,
NULL
,
prot
,
length
,
NULL
);
if
(
hMap
!=
INVALID_HANDLE_VALUE
)
addr
=
MapViewOfFileFromApp
(
hMap
,
access
,
0
,
length
);
#else
DWORD
hLength
=
(
DWORD
)(
length
>>
32
);
DWORD
lLength
=
(
DWORD
)(
length
&
0xFFFFFFFF
);
hMap
=
CreateFileMapping
(
handle
,
NULL
,
prot
,
hLength
,
lLength
,
NULL
);
if
(
hMap
!=
INVALID_HANDLE_VALUE
)
addr
=
MapViewOfFile
(
hMap
,
access
,
0
,
0
,
length
);
DWORD
hLength
=
(
DWORD
)(
length
>>
32
);
DWORD
lLength
=
(
DWORD
)(
length
&
0xFFFFFFFF
);
hMap
=
CreateFileMapping
(
handle
,
NULL
,
prot
,
hLength
,
lLength
,
NULL
);
if
(
hMap
!=
INVALID_HANDLE_VALUE
)
addr
=
MapViewOfFile
(
hMap
,
access
,
0
,
0
,
length
);
#endif
if
(
addr
!=
NULL
)
return
vlc_frame_mapview_Alloc
(
hMap
,
addr
,
length
);
if
(
addr
!=
NULL
)
return
vlc_frame_mapview_Alloc
(
hMap
,
addr
,
length
);
CloseHandle
(
hMap
);
}
else
{
// fail early
errno
=
EBADF
;
return
NULL
;
}
CloseHandle
(
hMap
);
}
#else
(
void
)
write
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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