/* BFD back-end for WebAssembly modules.
- Copyright (C) 2017-2021 Free Software Foundation, Inc.
+ Copyright (C) 2017-2022 Free Software Foundation, Inc.
Based on srec.c, mmo.c, and binary.c
https://github.com/WebAssembly/design/blob/master/BinaryEncoding.md. */
#include "sysdep.h"
-#include "alloca-conf.h"
#include "bfd.h"
#include "libiberty.h"
#include "libbfd.h"
#include "wasm-module.h"
-#ifdef HAVE_LIMITS_H
#include <limits.h>
-#endif
#ifndef CHAR_BIT
#define CHAR_BIT 8
#endif
#define READ_LEB128(x, p, end) \
do \
{ \
- unsigned int length_read; \
- (x) = _bfd_safe_read_leb128 (abfd, (p), &length_read, \
- false, (end)); \
- (p) += length_read; \
- if (length_read == 0) \
+ if ((p) >= (end)) \
goto error_return; \
+ (x) = _bfd_safe_read_leb128 (abfd, &(p), false, (end)); \
} \
while (0)
return true;
error_return:
- bfd_release (abfd, symbols);
+ if (symbols)
+ bfd_release (abfd, symbols);
return false;
}