Skip to content
Snippets Groups Projects
Commit 62bb71cf authored by Nikita Zheleztsov's avatar Nikita Zheleztsov Committed by Vladimir Davydov
Browse files

icu: fix NULL dereference in `unum_clone`

If `dynamic_cast` fails, then NULL is returned. Even thought
assertion is set, we cannot rely on it, as we don't use debug
version of icu. Let's check if `rbnf` variable is not NULL
explicitly.

If it somehow turned out to be NULL, then memory allocation
error will be thrown.

Closes tarantool/security#61

NO_CHANGELOG=<security fix>
NO_DOC=<security fix>
NO_TEST=<third-party security fix>
parent 73b01ea5
No related branches found
No related tags found
Loading
......@@ -116,6 +116,7 @@ ExternalProject_Add(icu
${CMAKE_COMMAND} -E copy_if_different <BINARY_DIR>/uconfig.h <INSTALL_DIR>/include/unicode/uconfig.h
PATCH_COMMAND patch -d <SOURCE_DIR> -p1 -i "${PATCHES_DIR}/icu-tarantool-security-45.patch"
COMMAND patch -d <SOURCE_DIR> -p1 -i "${PATCHES_DIR}/icu-tarantool-security-59.patch"
COMMAND patch -d <SOURCE_DIR> -p1 -i "${PATCHES_DIR}/icu-tarantool-security-61.patch"
)
set(TARANTOOL_DEPENDS icu ${TARANTOOL_DEPENDS})
......
diff --git a/source/i18n/unum.cpp b/source/i18n/unum.cpp
index 7043f7a..0f70c5c 100644
--- a/source/i18n/unum.cpp
+++ b/source/i18n/unum.cpp
@@ -164,7 +164,9 @@ unum_clone(const UNumberFormat *fmt,
} else {
const RuleBasedNumberFormat* rbnf = dynamic_cast<const RuleBasedNumberFormat*>(nf);
U_ASSERT(rbnf != NULL);
- res = rbnf->clone();
+ if (rbnf != NULL) {
+ res = rbnf->clone();
+ }
}
if(res == 0) {
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment