Skip to content

Commit

Permalink
fix Cppcheck nullPointerRedundantCheck in sesman/chansrv/clipboard.c
Browse files Browse the repository at this point in the history
  • Loading branch information
firewave committed Sep 4, 2023
1 parent 843602c commit 7741c7e
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions sesman/chansrv/clipboard.c
Original file line number Diff line number Diff line change
Expand Up @@ -2759,9 +2759,6 @@ clipboard_event_property_notify(XEvent *xevent)
format_in_bytes = FORMAT_TO_BYTES(actual_format_return);
new_data_len = nitems_returned * format_in_bytes;
cptr = (char *) g_malloc(g_clip_s2c.total_bytes + new_data_len, 0);
g_memcpy(cptr, g_clip_s2c.data, g_clip_s2c.total_bytes);
g_free(g_clip_s2c.data);

if (cptr == NULL)
{
g_clip_s2c.data = 0;
Expand All @@ -2775,14 +2772,15 @@ clipboard_event_property_notify(XEvent *xevent)
XDeleteProperty(g_display, g_wnd, g_clip_s2c.property);
return 0;
}
g_memcpy(cptr, g_clip_s2c.data, g_clip_s2c.total_bytes);
g_free(g_clip_s2c.data);

LOG_DEVEL(LOG_LEVEL_DEBUG, "clipboard_event_property_notify: new_data_len %d", new_data_len);
g_clip_s2c.data = cptr;
g_memcpy(g_clip_s2c.data + g_clip_s2c.total_bytes, data, new_data_len);
g_clip_s2c.total_bytes += new_data_len;

if (data)
{
g_memcpy(g_clip_s2c.data + g_clip_s2c.total_bytes, data, new_data_len);
g_clip_s2c.total_bytes += new_data_len;
XFree(data);
}

Expand Down

0 comments on commit 7741c7e

Please sign in to comment.