x11/cliprdr: handle empty format names

The recently added strdup checks ignored the fact that format names
can be NULL.
This commit is contained in:
Bernhard Miklautz 2015-07-02 15:39:35 +02:00
parent 87c5377f42
commit b6a799e5d0
1 changed files with 11 additions and 8 deletions

View File

@ -835,16 +835,19 @@ static int xf_cliprdr_server_format_list(CliprdrClientContext* context, CLIPRDR_
{
format = &formatList->formats[i];
clipboard->serverFormats[i].formatId = format->formatId;
clipboard->serverFormats[i].formatName = _strdup(format->formatName);
if (!clipboard->serverFormats[i].formatName)
if (format->formatName)
{
for (--i; i >= 0; --i)
free(clipboard->serverFormats[i].formatName);
clipboard->serverFormats[i].formatName = _strdup(format->formatName);
if (!clipboard->serverFormats[i].formatName)
{
for (--i; i >= 0; --i)
free(clipboard->serverFormats[i].formatName);
clipboard->numServerFormats = 0;
free(clipboard->serverFormats);
clipboard->serverFormats = NULL;
return -1;
clipboard->numServerFormats = 0;
free(clipboard->serverFormats);
clipboard->serverFormats = NULL;
return -1;
}
}
}