Changeset 14573


Ignore:
Timestamp:
Oct 11, 2015, 4:15:19 PM (6 years ago)
Author:
mikedld
Message:

Improve error handling when formatting error messages on Windows

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/utils.c

    r14503 r14573  
    11221122                              FORMAT_MESSAGE_IGNORE_INSERTS,
    11231123                              NULL, code, 0, (LPWSTR)&wide_text, 0, NULL);
     1124  if (wide_size == 0)
     1125    return tr_strdup_printf ("Unknown error (0x%08x)", code);
    11241126
    11251127  if (wide_size != 0 && wide_text != NULL)
     
    11281130  LocalFree (wide_text);
    11291131
    1130   /* Most (all?) messages contain "\r\n" in the end, chop it */
    1131   text_size = strlen (text);
    1132   while (text_size > 0 &&
    1133          text[text_size - 1] >= '\0' &&
    1134          text[text_size - 1] <= ' ')
    1135     text[--text_size] = '\0';
     1132  if (text != NULL)
     1133    {
     1134      /* Most (all?) messages contain "\r\n" in the end, chop it */
     1135      text_size = strlen (text);
     1136      while (text_size > 0 && isspace ((uint8_t) text[text_size - 1]))
     1137        text[--text_size] = '\0';
     1138    }
    11361139
    11371140  return text;
Note: See TracChangeset for help on using the changeset viewer.