/[smeserver]/rpms/hal/sme7/hal-0.4.2-plug-hotplug-memleak.patch
ViewVC logotype

Annotation of /rpms/hal/sme7/hal-0.4.2-plug-hotplug-memleak.patch

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (hide annotations) (download)
Thu Mar 22 16:11:10 2012 UTC (12 years, 2 months ago) by slords
Branch: MAIN
CVS Tags: hal-0_4_2-9_0_el4_sme, hal-0_4_2-8_EL4, hal-0_4_2-9_el4_sme, HEAD
Import

1 slords 1.1 --- hal-0.4.2/hald/device_info.c.orig
2     +++ hal-0.4.2/hald/device_info.c
3     @@ -1,5 +1,5 @@
4     /***************************************************************************
5     - * CVSID: $Id: device_info.c,v 1.16.2.1 2004/11/22 21:53:50 david Exp $
6     + * CVSID: $Id: device_info.c,v 1.16.2.2 2005/03/28 19:15:19 david Exp $
7     *
8     * device_store.c : Search for .fdi files and merge on match
9     *
10     @@ -1026,15 +1026,22 @@
11     XML_Parser parser;
12     ParsingContext *parsing_context;
13    
14     - snprintf (buf, 511, "%s/%s", dir, filename);
15     + file = NULL;
16     + filebuf = NULL;
17     + parser = NULL;
18     + parsing_context = NULL;
19     +
20     + device_matched = FALSE;
21     +
22     + snprintf (buf, sizeof (buf), "%s/%s", dir, filename);
23    
24     /*HAL_INFO(("analysing file %s", buf)); */
25    
26     /* open file and read it into a buffer; it's a small file... */
27     file = fopen (buf, "r");
28     if (file == NULL) {
29     - perror ("fopen");
30     - return FALSE;
31     + HAL_ERROR (("Could not open file %s", buf));
32     + goto out;
33     }
34    
35     fseek (file, 0L, SEEK_END);
36     @@ -1042,25 +1049,27 @@
37     rewind (file);
38     filebuf = (char *) malloc (filesize);
39     if (filebuf == NULL) {
40     - perror ("malloc");
41     - fclose (file);
42     - return FALSE;
43     + HAL_ERROR (("Could not allocate %d bytes for file %s", filesize, buf));
44     + goto out;
45     }
46     fread (filebuf, sizeof (char), filesize, file);
47    
48     -
49     - /* ok, now parse the file (should probably reuse parser and say we are
50     - * not thread safe
51     - */
52     - parser = XML_ParserCreate (NULL);
53     -
54     /* initialize parsing context */
55     parsing_context =
56     (ParsingContext *) malloc (sizeof (ParsingContext));
57     if (parsing_context == NULL) {
58     - perror ("malloc");
59     - return FALSE;
60     + HAL_ERROR (("Could not allocate parsing context"));
61     + goto out;
62     + }
63     +
64     + /* TODO: reuse parser
65     + */
66     + parser = XML_ParserCreate (NULL);
67     + if (parser == NULL) {
68     + HAL_ERROR (("Could not allocate XML parser"));
69     + goto out;
70     }
71     +
72     parsing_context->depth = 0;
73     parsing_context->device_matched = FALSE;
74     parsing_context->match_ok = TRUE;
75     @@ -1095,9 +1104,15 @@
76     device_matched = parsing_context->device_matched;
77     }
78    
79     - free (filebuf);
80     - fclose (file);
81     - free (parsing_context);
82     +out:
83     + if (filebuf != NULL)
84     + free (filebuf);
85     + if (file != NULL)
86     + fclose (file);
87     + if (parser != NULL)
88     + XML_ParserFree (parser);
89     + if (parsing_context != NULL)
90     + free (parsing_context);
91    
92     return device_matched;
93     }

admin@koozali.org
ViewVC Help
Powered by ViewVC 1.2.1 RSS 2.0 feed