jordansissel / xdotool

fake keyboard/mouse input, window management, and more
Other
3.18k stars 316 forks source link

Memory leak with _xdo_populate_charcode_map #287

Open Suhail opened 4 years ago

Suhail commented 4 years ago

Hi there,

I am seeing this:

==50542== 7,416 bytes in 103 blocks are definitely lost in loss record 1,328 of 1,388
==50542==    at 0x4C31B25: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==50542==    by 0xD214B70: XkbGetMap (in /usr/lib/x86_64-linux-gnu/libX11.so.6.3.0)
==50542==    by 0xC93394B: _xdo_populate_charcode_map (xdo.c:1342)
==50542==    by 0xC93394B: xdo_new_with_opened_display (xdo.c:137)
==50542==    by 0xC87ED3F: InputSimulator::X11CapsLockOn(Napi::CallbackInfo const&) (simulator.cpp:362)

Code:

void send_caplock_press() {
  xdo_t *xdo = xdo_new(NULL);
  xdo_send_keysequence_window_down(xdo, CURRENTWINDOW, "Caps_Lock", 0);
  xdo_send_keysequence_window_up(xdo, CURRENTWINDOW, "Caps_Lock", 0);
  xdo_free(xdo);
}

Does this look like a valid xdo memory leak?

Version info: libxdo-dev is already the newest version (1:3.20160805.1-3)

I saw some updated versions that fix some memory leaks but I noticed the ubuntu pkg isn't up-to-date...

dpellegr commented 3 years ago

Same as https://github.com/jordansissel/xdotool/issues/189 Very easy fix but it seems like this repository has been abandoned