summaryrefslogtreecommitdiff
path: root/setup.c
diff options
context:
space:
mode:
authorHiroshi Inoue2016-02-27 02:23:23 +0000
committerHiroshi Inoue2016-02-27 11:20:10 +0000
commit4d44165af04d40e8aad405a9fbe31d7304c654c8 (patch)
treef38cc46822b8fc56ff8fd578713dc6783e528c93 /setup.c
parent4f45057a6ad848938e34eea278feba9ca0eaa0e5 (diff)
Fix NULL dereferences which causes application crash. Patch by Tsunakawa, Takayuki.
Diffstat (limited to 'setup.c')
-rw-r--r--setup.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/setup.c b/setup.c
index 77b38d3..e70d3be 100644
--- a/setup.c
+++ b/setup.c
@@ -486,12 +486,18 @@ cleanup:
tlen = strlen(emsg);
wermsg = (SQLWCHAR *) malloc(sizeof(SQLWCHAR) * (tlen + 1));
- ulen = utf8_to_ucs2_lf(emsg, SQL_NTS, FALSE, wermsg, tlen + 1, TRUE);
+ if (wermsg)
+ ulen = utf8_to_ucs2_lf(emsg, SQL_NTS, FALSE, wermsg, tlen + 1, TRUE);
+ else
+ ulen = (SQLULEN) -1;
if (ulen != (SQLULEN) -1)
{
allocstr = malloc(4 * tlen + 1);
- (void) wstrtomsg(wermsg, (int) tlen, allocstr, (int) (4 * tlen + 1));
- emsg = allocstr;
+ if (allocstr)
+ {
+ (void) wstrtomsg(wermsg, (int) tlen, allocstr, (int) (4 * tlen + 1));
+ emsg = allocstr;
+ }
}
#endif /* UNICODE_SUPPORT */