[PATCH V2] libx11:lcDefConv.c fix use before check

walter harms wharms at bfs.de
Fri Jun 6 23:54:34 PDT 2014


I am not am git expert, all patches are generated the same way,
can you tell me how the error looks like ?

re,
 wh

Am 07.06.2014 02:01, schrieb Alan Coopersmith:
> Sorry, but git am cannot apply this patch - even after fixing the missing
> white space that your mailer seems to have lost, it still doesn't match
> up to the code currently in git master.
> 
>     -alan-
> 
> On 06/ 4/14 05:47 AM, walter harms wrote:
>>
>> * Do not use variables before checked for NULL.
>> * remove some superfluid spaces (Mark Kettenis)
>>
>> Signed-off-by: Harms <wharms at bfs,de>
>> ---
>>   modules/lc/def/lcDefConv.c | 35 +++++++++++++++++++++++++----------
>>   1 file changed, 25 insertions(+), 10 deletions(-)
>>
>> diff --git a/modules/lc/def/lcDefConv.c b/modules/lc/def/lcDefConv.c
>> index 3cd5c22..e14f5aa 100644
>> --- a/modules/lc/def/lcDefConv.c
>> +++ b/modules/lc/def/lcDefConv.c
>> @@ -149,13 +149,14 @@ def_mbstowcs(
>>       XPointer *args,
>>       int num_args)
>>   {
>> -    const char *src = (const char *) *from;
>> +    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)--;
>> @@ -181,14 +182,16 @@ 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];
>>       int unconv = 0;
>>
>>       if (from == NULL || *from == NULL)
>> -    return 0;
>> +      return 0;
>> +
>> +    src = (const wchar_t *) *from;
>>
>>       while (*from_left && *to_left) {
>>       (*from_left)--;
>> @@ -214,7 +217,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;
>> @@ -223,6 +226,7 @@ mbstostr(
>>
>>       if (from == NULL || *from == NULL)
>>       return 0;
>> +    src = (const char *) *from;
>>
>>       while (*from_left && *to_left) {
>>       ch = *src++;
>> @@ -251,7 +255,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 +265,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 +296,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;
>> @@ -299,6 +305,7 @@ mbstocs(
>>
>>       if (from == NULL || *from == NULL)
>>       return 0;
>> +    src = (const char *) *from;
>>
>>       length = min(*from_left, *to_left);
>>
>> @@ -336,7 +343,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 +353,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 +407,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 +419,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,7 +478,7 @@ cstowcs(
>>       XPointer *args,
>>       int num_args)
>>   {
>> -    const char *src = (const char *) *from;
>> +  const char *src;
>>       wchar_t *dst = (wchar_t *) *to;
>>       CodeSet codeset;
>>       XlcCharSet charset;
>> @@ -479,6 +490,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 +552,15 @@ 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++;
>>
> 
> 


More information about the xorg-devel mailing list