Package: csound / 1:6.12.2~dfsg-3.1

finish-botched-edit-in-zak.c.patch Patch series | download
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
From: John ffitch <jpff@codemist.co.uk>
Date: Tue, 11 Dec 2018 17:13:54 +0000
Subject: finish botched edit in zak.c

---
 InOut/widgets.cpp |  6 ++++--
 Opcodes/zak.c     | 21 +++++++++++++++------
 2 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/InOut/widgets.cpp b/InOut/widgets.cpp
index c50be84..ca0ab0a 100644
--- a/InOut/widgets.cpp
+++ b/InOut/widgets.cpp
@@ -3240,7 +3240,7 @@ extern "C" {
   {
       //char *text = p->itext->data;
       Fl_Box *o =  new Fl_Box((int)*p->ix, (int)*p->iy,
-                              (int)*p->iwidth, (int)*p->iheight, text);
+                              (int)*p->iwidth, (int)*p->iheight, strdup(text));
       widget_attributes(csound, o);
       Fl_Boxtype type;
       int itype = (int) *p->itype;
@@ -3324,6 +3324,7 @@ extern "C" {
       char *text = p->itext->data;
       ADDR_SET_VALUE v = widgetGlobals->AddrSetValue[(int) *p->ihandle];
       Fl_Widget *o = (Fl_Widget *) v.WidgAddress;
+      free((void*)o->label());
       o->label(text);
       return OK;
   }
@@ -3338,7 +3339,8 @@ extern "C" {
       Fl_Widget *o = (Fl_Widget *) v.WidgAddress;
       if (i<0 || i>csound->GetStrsmax(csound)) text = (char *) "???";
       else if ((text=csound->GetStrsets(csound,i))==NULL) text = (char *) "???";
-      o->label(text);
+      free((void*)o->label());
+      o->label(strdup(text));
       return OK;
   }
 
diff --git a/Opcodes/zak.c b/Opcodes/zak.c
index ae3619e..de10b99 100644
--- a/Opcodes/zak.c
+++ b/Opcodes/zak.c
@@ -177,10 +177,15 @@ int32_t zir(CSOUND *csound, ZKR *p)
 {
     /* See zkr() for more comments.  */
     int32_t    indx;
-    ZAK_GLOBALS* zak = (ZAK_GLOBALS*) p->zz;
+    ZAK_GLOBALS* zak;
 
-    if (UNLIKELY(zak == NULL))
-      return NOTOK;
+    if (UNLIKELY(zkset(csound, (ZKR*)p)!=OK))
+      return csound->InitError(csound, Str("No zk space: "
+                                           "zakinit has not been called yet."));
+    zak = (ZAK_GLOBALS*) p->zz;
+
+    /* if (UNLIKELY(zak == NULL)) */
+    /*   return NOTOK; */
     /* Check to see this index is within the limits of zk space. */
     indx = (int32_t) *p->ndx;
     if (UNLIKELY(indx > zak->zklast)) {
@@ -236,10 +241,14 @@ int32_t zkw(CSOUND *csound, ZKW *p)
 int32_t ziw(CSOUND *csound, ZKW *p)
 {
     int32_t    indx;
-    ZAK_GLOBALS* zak = (ZAK_GLOBALS*) p->zz;
+    ZAK_GLOBALS* zak;
 
-    if (UNLIKELY(zak==NULL))
-      return NOTOK;
+    if (UNLIKELY(zkset(csound, (ZKR*)p)!= OK))
+      return csound->InitError(csound, Str("No zk space: "
+                                           "zakinit has not been called yet."));
+    zak = p->zz;
+    /* if (UNLIKELY(zak==NULL)) */
+    /*   return NOTOK; */
     indx = (int32_t) *p->ndx;
     if (UNLIKELY(indx > zak->zklast)) {
       return csound->InitError(csound, Str("ziw index > isizek. Not writing."));