diff --git a/convert.c b/convert.c index 0e7bd37..575971c 100644 --- a/convert.c +++ b/convert.c @@ -4256,7 +4256,15 @@ inolog("ipara=%p paramType=%d %d proc_return=%d\n", ipara, ipara ? ipara->paramT allocbuf = malloc(WCLEN * (used + 1)); if (allocbuf) { - used = msgtowstr(buffer, (int) used, (LPWSTR) allocbuf, (int) (used + 1)); + if (used != 0 && + (used = msgtowstr(buffer, (int) used, (LPWSTR) allocbuf, (int) (used + 1))) == 0) + { + qb->errormsg = "Could not convert to SQL_C_CHAR"; + qb->errornumber = STMT_EXEC_ERROR; + CVT_TERMINATE(qb); + retval = SQL_ERROR; + goto cleanup; + } buf = ucs2_to_utf8((SQLWCHAR *) allocbuf, used, &used, FALSE); free(allocbuf); allocbuf = buf;