Browse Source

Fix memory leak after processing udev

Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
Slávek Banko 2 years ago
parent
commit
0a8417d414
1 changed files with 8 additions and 2 deletions
  1. 8
    2
      tdekbdledsync/main.cpp

+ 8
- 2
tdekbdledsync/main.cpp View File

@@ -467,11 +467,15 @@ int main() {
467 467
 				else {
468 468
 					dev = udev_monitor_receive_device(mon);
469 469
 					if (dev) {
470
+						int reload_keyboards = 0;
470 471
 						if (strcmp(udev_device_get_action(dev), "add") == 0) {
471
-							// Reload keyboards
472
-							break;
472
+							reload_keyboards = 1;
473 473
 						}
474 474
 						if (strcmp(udev_device_get_action(dev), "remove") == 0) {
475
+							reload_keyboards = 1;
476
+						}
477
+						udev_device_unref(dev);
478
+						if( reload_keyboards ) {
475 479
 							// Reload keyboards
476 480
 							break;
477 481
 						}
@@ -507,5 +511,7 @@ int main() {
507 511
 	}
508 512
 
509 513
 	releaseLock(lockfd, lockFileName);
514
+	udev_monitor_unref(mon);
515
+	udev_unref(udev);
510 516
 	return 0;
511 517
 }

Loading…
Cancel
Save