修复指定非法locale的内存泄漏问题

(cherry picked commit from <gitee.com//opengauss/openGauss-server/commit/ade2570c4e1a3f2a086f30b011bf5f1021088933>
This commit is contained in:
chenxiaobin19
2024-09-26 09:56:48 +08:00
committed by chenxiaobin
parent 72796eb739
commit c6ebce3448

View File

@ -420,9 +420,11 @@ char* gs_perm_setlocale_r(int category, const char* locale)
else
category_mask = (1 << (unsigned int)category);
t_thrd.port_cxt.save_locale_r = newlocale(category_mask, locale, t_thrd.port_cxt.save_locale_r);
if (t_thrd.port_cxt.save_locale_r == (locale_t)0)
locale_t newLocale = newlocale(category_mask, locale, t_thrd.port_cxt.save_locale_r);
if (newLocale == (locale_t)0) {
return NULL;
}
t_thrd.port_cxt.save_locale_r = newLocale;
old_locale = uselocale(t_thrd.port_cxt.save_locale_r);
if (old_locale == (locale_t)0)
return NULL;