~ubuntu-branches/ubuntu/oneiric/collectd/oneiric

« back to all changes in this revision

Viewing changes to debian/patches/snmp_memleak.dpatch

  • Committer: Bazaar Package Importer
  • Author(s): Morten Kjeldgaard
  • Date: 2008-11-18 15:54:20 UTC
  • mfrom: (1.1.5 upstream) (3.1.1 lenny)
  • Revision ID: james.westby@ubuntu.com-20081118155420-sc2mxv2pebafkmon
Tags: 4.4.2-2ubuntu1
* Merge from Debian unstable (LP: #298828). Remaining Ubuntu changes:
* Add ubuntu_in6-glibc28.dpatch patch, fix FTBFS.
* Add ubuntu_hardening.dpatch patch, fix FTBFS.
* Add ubuntu_perl.c.dpatch, fix FTBFS.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#! /bin/sh /usr/share/dpatch/dpatch-run
 
2
## snmp_memleak.dpatch by Florian Forster <octo@noris.net>
 
3
##
 
4
## DP: Fix a possible memory leak in the snmp plugin: The SNMP result object
 
5
## DP: was not freed when `csnmp_instance_list_add' failed.
 
6
## DP: (This is upstream Git commit 0109e3c1f3a515ed716ddbdc261e0ed2e3f8e640)
 
7
 
 
8
@DPATCH@
 
9
 
 
10
diff a/src/snmp.c b/src/snmp.c
 
11
--- a/src/snmp.c
 
12
+++ b/src/snmp.c
 
13
@@ -1120,10 +1120,6 @@ static int csnmp_read_table (host_definition_t *host, data_definition_t *data)
 
14
     vb = res->variables;
 
15
     if (vb == NULL)
 
16
     {
 
17
-      if (res != NULL)
 
18
-       snmp_free_pdu (res);
 
19
-      res = NULL;
 
20
-
 
21
       status = -1;
 
22
       break;
 
23
     }
 
24
@@ -1132,10 +1128,7 @@ static int csnmp_read_table (host_definition_t *host, data_definition_t *data)
 
25
      * subtree */
 
26
     if (csnmp_check_res_left_subtree (host, data, res) != 0)
 
27
     {
 
28
-      if (res != NULL)
 
29
-       snmp_free_pdu (res);
 
30
-      res = NULL;
 
31
-
 
32
+      status = 0;
 
33
       break;
 
34
     }
 
35
 
 
36
@@ -1157,11 +1150,7 @@ static int csnmp_read_table (host_definition_t *host, data_definition_t *data)
 
37
          (vb != NULL) && (vb->next_variable != NULL);
 
38
          vb = vb->next_variable)
 
39
        /* do nothing */;
 
40
-      if (vb == NULL)
 
41
-      {
 
42
-       status = -1;
 
43
-       break;
 
44
-      }
 
45
+      assert (vb != NULL);
 
46
 
 
47
       /* Copy OID to oid_list[data->values_len] */
 
48
       memcpy (oid_list[data->values_len].oid, vb->name,
 
49
@@ -1224,6 +1213,10 @@ static int csnmp_read_table (host_definition_t *host, data_definition_t *data)
 
50
     res = NULL;
 
51
   } /* while (status == 0) */
 
52
 
 
53
+  if (res != NULL)
 
54
+    snmp_free_pdu (res);
 
55
+  res = NULL;
 
56
+
 
57
   if (status == 0)
 
58
     csnmp_dispatch_table (host, data, instance_list, value_table);
 
59