summaryrefslogtreecommitdiff
path: root/src/w32proc.c
diff options
context:
space:
mode:
authorEli Zaretskii <eliz@gnu.org>2019-03-23 10:31:06 +0200
committerEli Zaretskii <eliz@gnu.org>2019-03-23 10:31:06 +0200
commit86c3cd99bff27e35e25dec0ee3f0dc4536b171ea (patch)
tree57b1d1f6e8a2ddceea6d8f6329b13b5f0a338777 /src/w32proc.c
parent068cbed32abfeb4e141cd5f56dedb084539ac7b7 (diff)
downloademacs-86c3cd99bff27e35e25dec0ee3f0dc4536b171ea.tar.gz
Avoid compiler warning in w32proc.c
* src/w32proc.c (w32_executable_type): Avoid compiler warnings about potential NULL pointer dereferencing.
Diffstat (limited to 'src/w32proc.c')
-rw-r--r--src/w32proc.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/w32proc.c b/src/w32proc.c
index 8e878e6ef3e..75e345a525a 100644
--- a/src/w32proc.c
+++ b/src/w32proc.c
@@ -1776,22 +1776,27 @@ w32_executable_type (char * filename,
if (data_dir)
{
/* Look for Cygwin DLL in the DLL import list. */
- IMAGE_DATA_DIRECTORY import_dir =
- data_dir[IMAGE_DIRECTORY_ENTRY_IMPORT];
+ IMAGE_DATA_DIRECTORY import_dir
+ = data_dir[IMAGE_DIRECTORY_ENTRY_IMPORT];
/* Import directory can be missing in .NET DLLs. */
if (import_dir.VirtualAddress != 0)
{
+ IMAGE_SECTION_HEADER *section
+ = rva_to_section (import_dir.VirtualAddress, nt_header);
+ if (!section)
+ emacs_abort ();
+
IMAGE_IMPORT_DESCRIPTOR * imports =
- RVA_TO_PTR (import_dir.VirtualAddress,
- rva_to_section (import_dir.VirtualAddress,
- nt_header),
+ RVA_TO_PTR (import_dir.VirtualAddress, section,
executable);
for ( ; imports->Name; imports++)
{
- IMAGE_SECTION_HEADER * section =
- rva_to_section (imports->Name, nt_header);
+ section = rva_to_section (imports->Name, nt_header);
+ if (!section)
+ emacs_abort ();
+
char * dllname = RVA_TO_PTR (imports->Name, section,
executable);