1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-16 08:40:19 +02:00

'load-thunk-from-memory' reports the correct error.

Previously 'load-thunk-from-memory' would often throw to 'system-error'
when passed an incorrect ELF file, leading to incorrect error messages.

* libguile/loader.c (load_thunk_from_memory): Reset 'errno' when
'check_elf_header' returns non-NULL.
* test-suite/tests/vm.test: New file.
* test-suite/Makefile.am (SCM_TESTS): Add it.
This commit is contained in:
Ludovic Courtès 2017-12-22 11:40:27 +01:00
parent 6d391bf1a4
commit deef64a739
3 changed files with 60 additions and 2 deletions

View file

@ -1,5 +1,5 @@
/* Copyright (C) 2001, 2009, 2010, 2011, 2012
* 2013, 2014, 2015 Free Software Foundation, Inc.
* 2013, 2014, 2015, 2017 Free Software Foundation, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
@ -362,7 +362,10 @@ load_thunk_from_memory (char *data, size_t len, int is_read_only)
header = (Elf_Ehdr*) data;
if ((err_msg = check_elf_header (header)))
goto cleanup;
{
errno = 0; /* not an OS error */
goto cleanup;
}
if (header->e_phnum == 0)
ABORT ("no loadable segments");