Skip to content

Commit f3050ff

Browse files
chuckcranorsoumagne
authored andcommitted
HG Core: prevent hg_core_init() segv on version check error
Go to "error_free" instead of "error" in the HG_CHECK_SUBSYS_ERROR() check for newer versions to avoid a core dump. hg_core_class is NULL (have not called calloc yet) and "error" assumes it is not. Issue found by Sheng Jiang.
1 parent 0a7756d commit f3050ff

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/mercury_core.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1210,7 +1210,8 @@ hg_core_init(const char *na_info_string, bool na_listen, unsigned int version,
12101210
/* Prevent newer versions */
12111211
HG_CHECK_SUBSYS_ERROR(cls,
12121212
HG_VERSION_LT(HG_VERSION(HG_VERSION_MAJOR, HG_VERSION_MINOR), version),
1213-
error, ret, HG_INVALID_ARG, "API version cannot be newer than library");
1213+
error_free, ret, HG_INVALID_ARG,
1214+
"API version cannot be newer than library");
12141215

12151216
/* Create new HG class */
12161217
hg_core_class =

0 commit comments

Comments
 (0)