Commit aa7053b3 authored by walter harms's avatar walter harms Committed by Ulrich Sibiller

lcDefConv.c: fix use before check

* Do not use variables before checked for NULL. * remove some superfluid spaces (Mark Kettenis) Signed-off-by: 's avatarHarms <wharms@bfs,de> Reviewed-by: 's avatarAlan Coopersmith <alan.coopersmith@oracle.com> Signed-off-by: 's avatarAlan Coopersmith <alan.coopersmith@oracle.com> Backported-to-NX-by: 's avatarUlrich Sibiller <uli42@gmx.de>
parent dd6dc2dd
......@@ -149,14 +149,16 @@ def_mbstowcs(
XPointer *args,
int num_args)
{
const char *src = (const char *) *from;
wchar_t *dst = (wchar_t *) * to;
const char *src;
wchar_t *dst = (wchar_t *) *to;
State state = (State) conv->state;
int unconv = 0;
if (from == NULL || *from == NULL)
return 0;
src = (const char *) *from;
while (*from_left && *to_left) {
(*from_left)--;
if (state->MBtoWC (state, src++, dst)) {
......@@ -181,7 +183,7 @@ def_wcstombs(
XPointer *args,
int num_args)
{
const wchar_t *src = (const wchar_t *) * from;
const wchar_t *src;
char *dst = (char *) *to;
State state = (State) conv->state;
char ch[MB_LEN_MAX];
......@@ -190,6 +192,8 @@ def_wcstombs(
if (from == NULL || *from == NULL)
return 0;
src = (const wchar_t *) *from;
while (*from_left && *to_left) {
(*from_left)--;
if (state->WCtoMB (state, *src++, ch)) {
......@@ -214,7 +218,7 @@ mbstostr(
XPointer *args,
int num_args)
{
const char *src = (const char *) *from;
const char *src;
char *dst = (char *) *to;
CodeSet codeset;
State state = (State) conv->state;
......@@ -224,6 +228,8 @@ mbstostr(
if (from == NULL || *from == NULL)
return 0;
src = (const char *) *from;
while (*from_left && *to_left) {
ch = *src++;
(*from_left)--;
......@@ -251,7 +257,7 @@ wcstostr(
XPointer *args,
int num_args)
{
const wchar_t *src = (const wchar_t *) *from;
const wchar_t *src;
char *dst = (char *) *to;
CodeSet codeset;
State state = (State) conv->state;
......@@ -261,6 +267,8 @@ wcstostr(
if (from == NULL || *from == NULL)
return 0;
src = (const wchar_t *) *from;
while (*from_left && *to_left) {
(*from_left)--;
if (state->WCtoMB (state, *src++, ch)) {
......@@ -290,7 +298,7 @@ mbstocs(
XPointer *args,
int num_args)
{
const char *src = (const char *) *from;
const char *src;
char *dst = (char *) *to;
int length;
State state = (State) conv->state;
......@@ -300,6 +308,7 @@ mbstocs(
if (from == NULL || *from == NULL)
return 0;
src = (const char *) *from;
length = min(*from_left, *to_left);
cur_side = *src & GR;
......@@ -336,7 +345,7 @@ wcstocs(
XPointer *args,
int num_args)
{
const wchar_t *src = (const wchar_t *) * from;
const wchar_t *src;
char *dst = (char *) *to;
State state = (State) conv->state;
char cur_side = 0, ch[MB_LEN_MAX];
......@@ -346,6 +355,8 @@ wcstocs(
if (from == NULL || *from == NULL)
return 0;
src = (const wchar_t *) *from;
while (*from_left) {
if ((found = state->WCtoMB (state, *src, ch)))
break;
......@@ -398,7 +409,7 @@ cstombs(
XPointer *args,
int num_args)
{
const char *src = (const char *) *from;
const char *src;
char *dst = (char *) *to;
CodeSet codeset;
XlcCharSet charset;
......@@ -410,6 +421,8 @@ cstombs(
if (from == NULL || *from == NULL)
return 0;
src = (const char *) *from;
if (num_args > 0) {
charset = (XlcCharSet) args[0];
if (charset == NULL)
......@@ -467,8 +480,8 @@ cstowcs(
XPointer *args,
int num_args)
{
const char *src = (const char *) *from;
wchar_t *dst = (wchar_t *) * to;
const char *src;
wchar_t *dst = (wchar_t *) *to;
CodeSet codeset;
XlcCharSet charset;
State state = (State) conv->state;
......@@ -479,6 +492,8 @@ cstowcs(
if (from == NULL || *from == NULL)
return 0;
src = (const char *) *from;
if (num_args > 0) {
charset = (XlcCharSet) args[0];
if (charset == NULL)
......@@ -539,13 +554,14 @@ strtombs(
XPointer *args,
int num_args)
{
const char *src = (const char *) *from;
const char *src;
char *dst = (char *) *to;
int length;
if (from == NULL || *from == NULL)
return 0;
src = (const char *) *from;
length = min(*from_left, *to_left);
while (length) {
*dst++ = *src++;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment