summaryrefslogtreecommitdiff
blob: a36a0a19ef8ec25501afe0a8510de2dbf2ecfe45 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#! /bin/sh /usr/share/dpatch/dpatch-run
## 02_asprintf.dpatch by Tobias Grimm <tg@e-tobi.net>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Fixes wrong usage of asprintf and correctly free's memory allocated by it.

This patch was extracted from http://e-tobi.net/vdr-experimental/pool/source/vdr/vdr-plugin-submenu_0.0.2-20.diff.gz


@DPATCH@
diff -urNad --exclude=CVS --exclude=.svn ./submenu-setup.c /tmp/dpep-work.ho7VxE/vdr-plugin-submenu-0.0.2/submenu-setup.c
--- ./submenu-setup.c	2005-02-03 15:35:49.000000000 +0100
+++ /tmp/dpep-work.ho7VxE/vdr-plugin-submenu-0.0.2/submenu-setup.c	2005-08-24 00:37:43.000000000 +0200
@@ -245,19 +245,25 @@
 void cSubMenuSetup::DrawSubMenu(int level)
 {
 	curLevel++;
-	char *line;
+	char *line, *tmp;
 	for(int i=0;i<SMSetup.Arbo.MaxItem[level];i++)
 	{
 		asprintf(&line,"%s","");
 		for (int z=0;z<curLevel*5;z++)
 		{
-			asprintf(&line,"%s ",line);
+			tmp = line;
+			asprintf(&line,"%s ",tmp);
+			free(tmp);
 		}
 		if (SMSetup.subMenuItem[SMSetup.Arbo.Index[level][i]].kindOfItem!=0)
 		{
-			asprintf(&line,"%s+",line);
+			tmp = line;
+			asprintf(&line,"%s+",tmp);
+			free(tmp);
 		}
-		asprintf(&line,"%s%s",line,tr(SMSetup.subMenuItem[SMSetup.Arbo.Index[level][i]].name));
+		tmp = line;
+		asprintf(&line,"%s%s",tmp,tr(SMSetup.subMenuItem[SMSetup.Arbo.Index[level][i]].name));
+		free(tmp);
 		Add (new cOsdItem(line),true);
 		SMSetup.Arbo.CurrentIndex[Current()]=SMSetup.Arbo.Index[level][i];
 		if (SMSetup.subMenuItem[SMSetup.Arbo.Index[level][i]].kindOfItem!=0)
@@ -265,23 +271,26 @@
 		   DrawSubMenu(SMSetup.subMenuItem[SMSetup.Arbo.Index[level][i]].kindOfItem);
 		   curLevel--;
 		}
+		free(line);
 	}
-	delete line;
 }
 
 void cSubMenuSetup::DrawMenu(void)
 {
 	int cur=Current();
 	Clear();
-	char *line;
+	char *line, *tmp;
 	for (int j=0;j<SMSetup.Arbo.MaxItem[0];j++)
 	{
 		asprintf(&line,"%s"," ");
 		if (SMSetup.subMenuItem[SMSetup.Arbo.Index[0][j]].kindOfItem!=0)
 		{
+			free(line);
 			asprintf(&line,"+");
 		}
-		asprintf(&line,"%s%s",line,tr(SMSetup.subMenuItem[SMSetup.Arbo.Index[0][j]].name));
+		tmp = line; 
+		asprintf(&line,"%s%s",tmp,tr(SMSetup.subMenuItem[SMSetup.Arbo.Index[0][j]].name));
+		free(tmp);
 		Add (new cOsdItem(line),true);
 		SMSetup.Arbo.CurrentIndex[Current()]=SMSetup.Arbo.Index[0][j];
 		if (SMSetup.subMenuItem[SMSetup.Arbo.Index[0][j]].kindOfItem!=0)
@@ -289,10 +298,10 @@
 			DrawSubMenu(SMSetup.subMenuItem[SMSetup.Arbo.Index[0][j]].kindOfItem);
 			curLevel--;
 		}
+		free(line);
 	}
 	SetCurrent(Get(cur));
 	Display();
-	delete line;
 }