Skip to content
Commit 9455ad7c authored by Marius Vlad's avatar Marius Vlad Committed by Pekka Paalanen
Browse files

backend-rdp/rdpclip: Avoid printing negative index



As clipboard_find_supported_format_by_mime_type() can return -1 if it
can't find out an index avoid trying to print outside of the array.

Fixes the following warnings triggered when enabling FORTIFY_SOURCE
combined with optimizations (-O)

../libweston/backend-rdp/rdpclip.c:1114:17: error: array subscript -1 is below array bounds of ‘uint32_t[5]’ {aka ‘unsigned int[5]’} [-Werror=array-bounds]
 1114 |                 weston_log("RDP %s (%p:%s) specified format \"%s\" index:%d formatId:%d is not supported by client\n",
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1115 |                            __func__, source, clipboard_data_source_state_to_string(source),
      |                            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1116 |                            mime_type, index, source->client_format_id_table[index]);
      |                            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../libweston/backend-rdp/rdpclip.c:131:18: note: while referencing ‘client_format_id_table’
  131 |         uint32_t client_format_id_table[RDP_NUM_CLIPBOARD_FORMATS];

Signed-off-by: default avatarMarius Vlad <marius.vlad@collabora.com>
parent 1cb46994
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment