Переглянути джерело

cmDspFx.c : Added missing va_end() to match va_copy().

master
kevin 10 роки тому
джерело
коміт
681865e04b
1 змінених файлів з 47 додано та 10 видалено
  1. 47
    10
      dsp/cmDspFx.c

+ 47
- 10
dsp/cmDspFx.c Переглянути файл

@@ -199,7 +199,6 @@ typedef struct
199 199
 cmDspInst_t*  _cmDspMtDelayAlloc(cmDspCtx_t* ctx, cmDspClass_t* classPtr, unsigned storeSymId, unsigned instSymId, unsigned id, unsigned va_cnt, va_list vl )
200 200
 {
201 201
   va_list vl1;
202
-  va_copy(vl1,vl);
203 202
 
204 203
   cmDspVarArg_t args[] =
205 204
   {
@@ -217,6 +216,8 @@ cmDspInst_t*  _cmDspMtDelayAlloc(cmDspCtx_t* ctx, cmDspClass_t* classPtr, unsign
217 216
     return NULL;
218 217
   }    
219 218
 
219
+  va_copy(vl1,vl);
220
+
220 221
   unsigned      reqArgCnt    = 3;
221 222
   unsigned      fixArgCnt    = sizeof(args)/sizeof(args[0]);
222 223
   unsigned      tapCnt       = (va_cnt - reqArgCnt)/2;
@@ -261,7 +262,7 @@ cmDspInst_t*  _cmDspMtDelayAlloc(cmDspCtx_t* ctx, cmDspClass_t* classPtr, unsign
261 262
     cmDspSetDefaultDouble(ctx,&p->inst,baseGainMtId+i,  0.0, gainV[i]);
262 263
   }
263 264
   
264
-
265
+  va_end(vl1);
265 266
   return &p->inst;
266 267
 }
267 268
 
@@ -985,8 +986,6 @@ cmDspInst_t*  _cmDspAutoGainAlloc(cmDspCtx_t* ctx, cmDspClass_t* classPtr, unsig
985 986
   va_list             vl1;
986 987
   unsigned            i;
987 988
 
988
-  // copy the va_list so that it can be used again in cmDspInstAlloc()
989
-  va_copy(vl1,vl);
990 989
 
991 990
   // verify that at least one var arg exists
992 991
   if( va_cnt < 1 )
@@ -994,6 +993,8 @@ cmDspInst_t*  _cmDspAutoGainAlloc(cmDspCtx_t* ctx, cmDspClass_t* classPtr, unsig
994 993
     cmDspClassErr(ctx,classPtr,kInvalidArgDspRC,"The AutoGain constructor must be given the audio channel count as its first argument.");
995 994
     return NULL;
996 995
   }    
996
+  // copy the va_list so that it can be used again in cmDspInstAlloc()
997
+  va_copy(vl1,vl);
997 998
 
998 999
   // get the first var arg which should be a filename
999 1000
   unsigned chCnt = va_arg(vl,unsigned);
@@ -1001,6 +1002,7 @@ cmDspInst_t*  _cmDspAutoGainAlloc(cmDspCtx_t* ctx, cmDspClass_t* classPtr, unsig
1001 1002
   if( chCnt == 0 )
1002 1003
   {
1003 1004
     cmDspClassErr(ctx,classPtr,kInvalidArgDspRC,"The AutoGain constructor requires at least 1 audio channel.");
1005
+    va_end(vl1);
1004 1006
     return NULL;
1005 1007
   }
1006 1008
 
@@ -1038,6 +1040,8 @@ cmDspInst_t*  _cmDspAutoGainAlloc(cmDspCtx_t* ctx, cmDspClass_t* classPtr, unsig
1038 1040
   cmDspSetDefaultSymbol( ctx, &p->inst, kSelAgId, p->cancelSymId );
1039 1041
   cmDspSetDefaultInt(    ctx, &p->inst, kIdAgId,  0, cmInvalidId );
1040 1042
 
1043
+   va_end(vl1);
1044
+ 
1041 1045
   return &p->inst;
1042 1046
 }
1043 1047
 
@@ -1504,6 +1508,8 @@ cmDspInst_t*  _cmDspXfaderAlloc(cmDspCtx_t* ctx, cmDspClass_t* classPtr, unsigne
1504 1508
   for(i=0; i<chCnt; ++i)
1505 1509
     cmDspSetDefaultBool( ctx, &p->inst, stateBaseXfId+i, false, false );
1506 1510
 
1511
+  va_end(vl1);
1512
+
1507 1513
   return &p->inst;
1508 1514
 }
1509 1515
 
@@ -1900,6 +1906,7 @@ cmDspInst_t*  _cmDspChordDetectAlloc(cmDspCtx_t* ctx, cmDspClass_t* classPtr, un
1900 1906
 
1901 1907
   if( cmDspRsrcUIntArray( ctx->dspH, &chCnt, &enaV, rsrc, NULL ) != kOkDspRC )
1902 1908
   {
1909
+    va_end(vl1);
1903 1910
     cmDspClassErr(ctx,classPtr,kInvalidArgDspRC,"The chord detector channel index resource '%s' could not be read.",cmStringNullGuard(rsrc));
1904 1911
     return NULL;
1905 1912
   }
@@ -1942,6 +1949,7 @@ cmDspInst_t*  _cmDspChordDetectAlloc(cmDspCtx_t* ctx, cmDspClass_t* classPtr, un
1942 1949
   p->chRmsV        = cmMemAllocZ(cmReal_t, chCnt);
1943 1950
   p->chEnaV        = enaV;
1944 1951
 
1952
+  va_end(vl1);
1945 1953
 
1946 1954
   return &p->inst;
1947 1955
 }
@@ -2202,7 +2210,6 @@ cmDspInst_t*  _cmDspNoteSelectAlloc(cmDspCtx_t* ctx, cmDspClass_t* classPtr, uns
2202 2210
   }
2203 2211
 
2204 2212
   va_list vl1;
2205
-  va_copy(vl1,vl);
2206 2213
 
2207 2214
   unsigned        CD0chanN = 0;
2208 2215
   unsigned        CD1chanN = 0;
@@ -2223,6 +2230,7 @@ cmDspInst_t*  _cmDspNoteSelectAlloc(cmDspCtx_t* ctx, cmDspClass_t* classPtr, uns
2223 2230
     return NULL;
2224 2231
   }
2225 2232
 
2233
+  va_copy(vl1,vl);
2226 2234
 
2227 2235
   unsigned chCnt         = va_arg(vl,unsigned);
2228 2236
   unsigned fixArgCnt     = sizeof(args)/sizeof(args[0]);
@@ -2297,6 +2305,8 @@ cmDspInst_t*  _cmDspNoteSelectAlloc(cmDspCtx_t* ctx, cmDspClass_t* classPtr, uns
2297 2305
     cmDspSetDefaultBool(  ctx, &p->inst, gate4BaseNsId+i, false, p->chGroupV[i] == kGroupNonNsId );   
2298 2306
   }
2299 2307
 
2308
+  va_end(vl1);
2309
+
2300 2310
   return &p->inst;
2301 2311
 }
2302 2312
 
@@ -2903,7 +2913,7 @@ cmDspInst_t*  _cmDspScalarOpAlloc(cmDspCtx_t* ctx, cmDspClass_t* classPtr, unsig
2903 2913
   if( inPortCnt == 0 )
2904 2914
   {
2905 2915
     cmDspClassErr(ctx,classPtr,kVarNotValidDspRC,"The 'ScalarOp' constructor input port argument must be non-zero.");
2906
-    return NULL;
2916
+    goto errLabel;
2907 2917
   }
2908 2918
 
2909 2919
   // locate the operation function
@@ -2917,7 +2927,7 @@ cmDspInst_t*  _cmDspScalarOpAlloc(cmDspCtx_t* ctx, cmDspClass_t* classPtr, unsig
2917 2927
   if( fp == NULL )
2918 2928
   {
2919 2929
     cmDspClassErr(ctx,classPtr,kVarNotValidDspRC,"The 'ScalarOp' constructor operation string id '%s' did not match a known operation.",cmStringNullGuard(opIdStr));
2920
-    return NULL;
2930
+    goto errLabel;
2921 2931
   }
2922 2932
 
2923 2933
   // setup the fixed args
@@ -2937,7 +2947,7 @@ cmDspInst_t*  _cmDspScalarOpAlloc(cmDspCtx_t* ctx, cmDspClass_t* classPtr, unsig
2937 2947
   cmDspArgSetupNull( a+argCnt); // set terminating arg. flag
2938 2948
 
2939 2949
   if((p = cmDspInstAlloc(cmDspScalarOp_t,ctx,classPtr,a,instSymId,id,storeSymId,2,vl1)) == NULL )
2940
-    return NULL;
2950
+    goto errLabel;
2941 2951
 
2942 2952
   for(i=0; i<inPortCnt; ++i)
2943 2953
     cmDspSetDefaultDouble(ctx,&p->inst,kBaseOpdSoId+i,0.0,dfltVal[i]);
@@ -2945,8 +2955,14 @@ cmDspInst_t*  _cmDspScalarOpAlloc(cmDspCtx_t* ctx, cmDspClass_t* classPtr, unsig
2945 2955
   p->inPortCnt = inPortCnt;
2946 2956
   p->func      = fp;
2947 2957
   
2958
+  va_end(vl1);
2948 2959
 
2949 2960
   return &p->inst;
2961
+
2962
+ errLabel:
2963
+  va_end(vl1);
2964
+
2965
+  return NULL;
2950 2966
 }
2951 2967
 
2952 2968
 
@@ -3053,8 +3069,11 @@ cmDspInst_t*  _cmDspGroupSelAlloc(cmDspCtx_t* ctx, cmDspClass_t* classPtr, unsig
3053 3069
   cmDspArgSetupNull( a+argCnt); // set terminating arg. flag
3054 3070
 
3055 3071
   if((p = cmDspInstAlloc(cmDspGroupSel_t,ctx,classPtr,a,instSymId,id,storeSymId,va_cnt,vl1)) == NULL )
3072
+  {
3073
+    va_end(vl1);
3056 3074
     return NULL;
3057
-    
3075
+  }
3076
+ 
3058 3077
   p->chCnt       = chCnt;
3059 3078
   p->groupCnt    = groupCnt;
3060 3079
   p->gsp         = cmGroupSelAlloc(ctx->cmProcCtx, NULL, 0, 0, 0 );
@@ -3069,6 +3088,8 @@ cmDspInst_t*  _cmDspGroupSelAlloc(cmDspCtx_t* ctx, cmDspClass_t* classPtr, unsig
3069 3088
   for(i=0; i<outCnt; ++i)
3070 3089
     cmDspSetDefaultBool( ctx, &p->inst, baseOutGsId, false, false );
3071 3090
 
3091
+  va_end(vl1);
3092
+
3072 3093
   return &p->inst;
3073 3094
 }
3074 3095
 
@@ -3216,6 +3237,8 @@ cmDspInst_t*  _cmDspAudioNofM_Alloc(cmDspCtx_t* ctx, cmDspClass_t* classPtr, uns
3216 3237
   for(i=0; i<outChCnt; ++i)
3217 3238
     cmDspSetDefaultDouble( ctx, &p->inst, baseGainNmId + i, 0.0, 0.0 );
3218 3239
 
3240
+  va_end(vl1);
3241
+
3219 3242
   return &p->inst;
3220 3243
 }
3221 3244
 
@@ -3362,6 +3385,8 @@ cmDspInst_t*  _cmDspRingModAlloc(cmDspCtx_t* ctx, cmDspClass_t* classPtr, unsign
3362 3385
 
3363 3386
   p->inChCnt = inChCnt;
3364 3387
 
3388
+  va_end(vl1);
3389
+
3365 3390
   return &p->inst;
3366 3391
 }
3367 3392
 
@@ -4656,6 +4681,7 @@ cmDspInst_t*  _cmDspNofM_Alloc(cmDspCtx_t* ctx, cmDspClass_t* classPtr, unsigned
4656 4681
 
4657 4682
   if( oChCnt > iChCnt )
4658 4683
   {
4684
+    va_end(vl1);
4659 4685
     cmDspClassErr(ctx,classPtr,kVarArgParseFailDspRC,"The 'NofM' output count must be less than or equal to the input count.");
4660 4686
     return NULL;
4661 4687
   }
@@ -4721,6 +4747,8 @@ cmDspInst_t*  _cmDspNofM_Alloc(cmDspCtx_t* ctx, cmDspClass_t* classPtr, unsigned
4721 4747
 
4722 4748
   cmDspSetDefaultDouble( ctx, &p->inst, kXfadeMsNoId, 0.0, 15.0 );
4723 4749
 
4750
+  va_end(vl1);
4751
+
4724 4752
   return &p->inst;
4725 4753
 }
4726 4754
 
@@ -5071,6 +5099,8 @@ cmDspInst_t*  _cmDsp1ofN_Alloc(cmDspCtx_t* ctx, cmDspClass_t* classPtr, unsigned
5071 5099
   cmDspSetDefaultBool(   ctx, &p->inst, kOutBool1oId, false, false );
5072 5100
   cmDspSetDefaultSymbol( ctx, &p->inst, kOutSym1oId, cmInvalidId );
5073 5101
 
5102
+  va_end(vl1);
5103
+
5074 5104
   return &p->inst;
5075 5105
 }
5076 5106
 
@@ -5221,6 +5251,8 @@ cmDspInst_t*  _cmDsp1Up_Alloc(cmDspCtx_t* ctx, cmDspClass_t* classPtr, unsigned
5221 5251
   for(i=0; i<chCnt; ++i)
5222 5252
     cmDspSetDefaultBool(   ctx, &p->inst, kBaseOut1uId + i, false, false );
5223 5253
 
5254
+  va_end(vl1);
5255
+
5224 5256
   return &p->inst;
5225 5257
 }
5226 5258
 
@@ -5407,6 +5439,7 @@ cmDspInst_t*  _cmDspPortToSym_Alloc(cmDspCtx_t* ctx, cmDspClass_t* classPtr, uns
5407 5439
 
5408 5440
   if( va_cnt < 1 )
5409 5441
   {
5442
+    va_end(vl1);
5410 5443
     cmDspClassErr(ctx,classPtr,kVarArgParseFailDspRC,"The 'PortToSym' constructor argument list must contain at least one symbol label.");
5411 5444
     return NULL;
5412 5445
   }
@@ -5448,6 +5481,7 @@ cmDspInst_t*  _cmDspPortToSym_Alloc(cmDspCtx_t* ctx, cmDspClass_t* classPtr, uns
5448 5481
 
5449 5482
   cmDspSetDefaultSymbol(ctx,&p->inst,kOutPtsId,cmInvalidId);
5450 5483
 
5484
+  va_end(vl1);
5451 5485
 
5452 5486
   return &p->inst;
5453 5487
 }
@@ -5580,6 +5614,8 @@ cmDspInst_t*  _cmDspRouter_Alloc(cmDspCtx_t* ctx, cmDspClass_t* classPtr, unsign
5580 5614
     cmDspSetDefaultSymbol( ctx, &p->inst, baseOutSymRtId+i, cmInvalidId );
5581 5615
   }
5582 5616
 
5617
+  va_end(vl1);
5618
+
5583 5619
   return &p->inst;
5584 5620
 }
5585 5621
 
@@ -5741,6 +5777,7 @@ cmDspInst_t*  _cmDspAvailCh_Alloc(cmDspCtx_t* ctx, cmDspClass_t* classPtr, unsig
5741 5777
 
5742 5778
   if( chCnt <= 0 )
5743 5779
   {
5780
+    va_end(vl1);
5744 5781
     cmDspClassErr(ctx,classPtr,kInvalidArgDspRC,"The 'AvailCh' constructor must be given a positive channel count.");
5745 5782
     return NULL;
5746 5783
   }
@@ -5771,7 +5808,7 @@ cmDspInst_t*  _cmDspAvailCh_Alloc(cmDspCtx_t* ctx, cmDspClass_t* classPtr, unsig
5771 5808
   cmDspSetDefaultUInt( ctx, &p->inst, kModeAvId,  0, kExclusiveModeAvId );
5772 5809
   cmDspSetDefaultUInt( ctx, &p->inst, kChIdxAvId, 0, cmInvalidIdx );
5773 5810
   
5774
-  
5811
+  va_end(vl1);
5775 5812
 
5776 5813
   return &p->inst;
5777 5814
 }

Завантаження…
Відмінити
Зберегти