~ubuntu-branches/ubuntu/utopic/thermald/utopic

« back to all changes in this revision

Viewing changes to debian/patches/0017-Fix-up-some-memory-leaks-in-THD_SUCCESS-branches.patch

  • Committer: Package Import Robot
  • Author(s): Colin King
  • Date: 2014-05-19 12:41:22 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20140519124122-zan11arvjxtbqcq5
Tags: 1.2-1
* Adjust for coretemp path change
* Deny non root users to send system bus dbus messages
* Remove compile warning
* Remove rpmlint warning for manual page
* Remove old patches that are now included into version 1.2
* Sync up with version 1.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
From 30e5450ec47bded0f48f1097515e2ce9f3e05e05 Mon Sep 17 00:00:00 2001
2
 
From: Colin Ian King <colin.king@canonical.com>
3
 
Date: Mon, 10 Mar 2014 09:31:19 +0000
4
 
Subject: [PATCH 17/28] Fix up some memory leaks in !THD_SUCCESS branches
5
 
 
6
 
In various THD_SUCCESS failure paths memory is being leaked, so
7
 
free them to stop the daemon leaking excessively.
8
 
 
9
 
Signed-off-by: Colin Ian King <colin.king@canonical.com>
10
 
---
11
 
 src/thd_engine.cpp         | 12 +++++++++---
12
 
 src/thd_engine_default.cpp | 12 ++++++++++--
13
 
 2 files changed, 19 insertions(+), 5 deletions(-)
14
 
 
15
 
diff --git a/src/thd_engine.cpp b/src/thd_engine.cpp
16
 
index 87e70e0..f00c616 100644
17
 
--- a/src/thd_engine.cpp
18
 
+++ b/src/thd_engine.cpp
19
 
@@ -609,8 +609,10 @@ void cthd_engine::thd_read_default_thermal_sensors() {
20
 
                                i = atoi(entry->d_name + strlen("thermal_zone"));
21
 
                                cthd_sensor *sensor = new cthd_sensor(i,
22
 
                                                base_path + entry->d_name + "/", "");
23
 
-                               if (sensor->sensor_update() != THD_SUCCESS)
24
 
+                               if (sensor->sensor_update() != THD_SUCCESS) {
25
 
+                                       delete sensor;
26
 
                                        continue;
27
 
+                               }
28
 
                                sensors.push_back(sensor);
29
 
                        }
30
 
                }
31
 
@@ -635,8 +637,10 @@ void cthd_engine::thd_read_default_thermal_zones() {
32
 
                                i = atoi(entry->d_name + strlen("thermal_zone"));
33
 
                                cthd_sysfs_zone *zone = new cthd_sysfs_zone(i,
34
 
                                                "/sys/class/thermal/thermal_zone");
35
 
-                               if (zone->zone_update() != THD_SUCCESS)
36
 
+                               if (zone->zone_update() != THD_SUCCESS) {
37
 
+                                       delete zone;
38
 
                                        continue;
39
 
+                               }
40
 
                                if (control_mode == EXCLUSIVE)
41
 
                                        zone->set_zone_active();
42
 
                                zones.push_back(zone);
43
 
@@ -664,8 +668,10 @@ void cthd_engine::thd_read_default_cooling_devices() {
44
 
                                i = atoi(entry->d_name + strlen("cooling_device"));
45
 
                                cthd_sysfs_cdev *cdev = new cthd_sysfs_cdev(i,
46
 
                                                "/sys/class/thermal/");
47
 
-                               if (cdev->update() != THD_SUCCESS)
48
 
+                               if (cdev->update() != THD_SUCCESS) {
49
 
+                                       delete cdev;
50
 
                                        continue;
51
 
+                               }
52
 
                                cdevs.push_back(cdev);
53
 
                        }
54
 
                }
55
 
diff --git a/src/thd_engine_default.cpp b/src/thd_engine_default.cpp
56
 
index 43e23c6..b75d899 100644
57
 
--- a/src/thd_engine_default.cpp
58
 
+++ b/src/thd_engine_default.cpp
59
 
@@ -107,8 +107,10 @@ int cthd_engine_default::read_thermal_sensors() {
60
 
                                                                        base_path + entry->d_name + "/"
61
 
                                                                                        + temp_input_str.str(),
62
 
                                                                        temp_input_str.str(), SENSOR_TYPE_RAW);
63
 
-                                                       if (sensor->sensor_update() != THD_SUCCESS)
64
 
+                                                       if (sensor->sensor_update() != THD_SUCCESS) {
65
 
+                                                               delete sensor;
66
 
                                                                return THD_ERROR;
67
 
+                                                       }
68
 
                                                        sensors.push_back(sensor);
69
 
                                                        ++index;
70
 
                                                }
71
 
@@ -127,8 +129,10 @@ int cthd_engine_default::read_thermal_sensors() {
72
 
                cthd_sensor *sensor = new cthd_sensor(index,
73
 
                                "/sys/class/hwmon/hwmon0/temp1_input", "hwmon",
74
 
                                SENSOR_TYPE_RAW);
75
 
-               if (sensor->sensor_update() != THD_SUCCESS)
76
 
+               if (sensor->sensor_update() != THD_SUCCESS) {
77
 
+                       delete sensor;
78
 
                        return THD_ERROR;
79
 
+               }
80
 
                sensors.push_back(sensor);
81
 
                ++index;
82
 
 
83
 
@@ -197,6 +201,8 @@ int cthd_engine_default::read_thermal_zones() {
84
 
                                                zones.push_back(zone);
85
 
                                                ++count;
86
 
                                                cpu_zone_created = true;
87
 
+                                       } else {
88
 
+                                               delete zone;
89
 
                                        }
90
 
                                }
91
 
                        }
92
 
@@ -214,6 +220,8 @@ int cthd_engine_default::read_thermal_zones() {
93
 
                                zones.push_back(zone);
94
 
                                ++count;
95
 
                                cpu_zone_created = true;
96
 
+                       } else {
97
 
+                               delete zone;
98
 
                        }
99
 
 
100
 
                        if (!cpu_zone_created) {
101
 
1.9.0
102