aboutsummaryrefslogtreecommitdiff
path: root/nx-X11
diff options
context:
space:
mode:
authorwalter harms <wharms@bfs.de>2014-06-07 12:03:17 +0200
committerUlrich Sibiller <uli42@gmx.de>2016-10-19 21:40:29 +0200
commitaa7053b3eea7c98e155caf6ff6fd652f55b0547e (patch)
tree77c9112b99e54f2a16f9665ae2bb3c0e3636a31a /nx-X11
parentdd6dc2ddfa8b0cb671711acb9d157de29a48c032 (diff)
downloadnx-libs-aa7053b3eea7c98e155caf6ff6fd652f55b0547e.tar.gz
nx-libs-aa7053b3eea7c98e155caf6ff6fd652f55b0547e.tar.bz2
nx-libs-aa7053b3eea7c98e155caf6ff6fd652f55b0547e.zip
lcDefConv.c: fix use before check
* Do not use variables before checked for NULL. * remove some superfluid spaces (Mark Kettenis) Signed-off-by: Harms <wharms@bfs,de> Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Backported-to-NX-by: Ulrich Sibiller <uli42@gmx.de>
Diffstat (limited to 'nx-X11')
-rw-r--r--nx-X11/lib/X11/lcDefConv.c38
1 files changed, 27 insertions, 11 deletions
diff --git a/nx-X11/lib/X11/lcDefConv.c b/nx-X11/lib/X11/lcDefConv.c
index e1f02289b..51ad2f8e7 100644
--- a/nx-X11/lib/X11/lcDefConv.c
+++ b/nx-X11/lib/X11/lcDefConv.c
@@ -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++;