From 9798bf372d38aee2237ad7a218fb61c18745f924 Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Thu, 24 Jul 2014 20:04:29 -0500 Subject: [PATCH] Check return value of wimlib_global_init() when called in lib On Windows, wimlib_global_init() can fail if functions are missing from ntdll. It's best to fail fast in this case rather than plowing ahead and assuming the user would have already called wimlib_global_init() themselves if they cared. --- src/mount_image.c | 4 +++- src/wim.c | 8 ++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/mount_image.c b/src/mount_image.c index f8e733d8..b53dfb5c 100644 --- a/src/mount_image.c +++ b/src/mount_image.c @@ -2478,7 +2478,9 @@ wimlib_unmount_image_with_progress(const char *dir, int unmount_flags, int mount_flags; int ret; - wimlib_global_init(WIMLIB_INIT_FLAG_ASSUME_UTF8); + ret = wimlib_global_init(WIMLIB_INIT_FLAG_ASSUME_UTF8); + if (ret) + return ret; if (unmount_flags & ~(WIMLIB_UNMOUNT_FLAG_CHECK_INTEGRITY | WIMLIB_UNMOUNT_FLAG_COMMIT | diff --git a/src/wim.c b/src/wim.c index 3ab0266b..3f09bc50 100644 --- a/src/wim.c +++ b/src/wim.c @@ -188,7 +188,9 @@ wimlib_create_new_wim(int ctype, WIMStruct **wim_ret) struct wim_lookup_table *table; int ret; - wimlib_global_init(WIMLIB_INIT_FLAG_ASSUME_UTF8); + ret = wimlib_global_init(WIMLIB_INIT_FLAG_ASSUME_UTF8); + if (ret) + return ret; DEBUG("Creating new WIM with %"TS" compression.", wimlib_get_compression_type_string(ctype)); @@ -817,7 +819,9 @@ open_wim_as_WIMStruct(const void *wim_filename_or_fd, int open_flags, else DEBUG("Opening WIM file \"%"TS"\"", (const tchar*)wim_filename_or_fd); - wimlib_global_init(WIMLIB_INIT_FLAG_ASSUME_UTF8); + ret = wimlib_global_init(WIMLIB_INIT_FLAG_ASSUME_UTF8); + if (ret) + return ret; if (wim_ret == NULL) return WIMLIB_ERR_INVALID_PARAM; -- 2.43.0