File tree Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -43,14 +43,22 @@ void AnalogEcho_Ctor(AnalogEcho* unit) {
4343 // Allocate the buffer. Do NOT use malloc!
4444 // SuperCollider provides special real-time-safe allocation and freeing functions.
4545 unit->buf = (float *)RTAlloc (unit->mWorld , unit->bufsize * sizeof (float ));
46+
47+ // This check makes sure that RTAlloc succeeded. (It might fail if there's not enough memory.)
48+ // If you don't do this check properly then YOU CAN CRASH THE SERVER!
49+ // A lot of ugens in core and sc3-plugins fail to do this. Don't follow their example.
4650 if (unit->buf == NULL ) {
51+ // Avoid retaining AnalogEcho_next as the calculation function.
4752 SETCALC (ft->fClearUnitOutputs );
4853 ClearUnitOutputs (unit, 1 );
4954
5055 if (unit->mWorld ->mVerbosity > -2 ) {
5156 Print (" Failed to allocate memory for AnalogEcho ugen.\n " );
5257 }
58+
59+ return ;
5360 }
61+
5462 // Fill the buffer with zeros.
5563 memset (unit->buf , 0 , unit->bufsize * sizeof (float ));
5664
You can’t perform that action at this time.
0 commit comments