ref: f9fe5cb507f5ae7a05ba80ab782dabcd8af55fc9
parent: 1adf351ed1e05372fb886d839dda126dc85727a0
author: Ellie <[email protected]>
date: Sun Nov 14 14:36:21 EST 2021
Fix new refCount allocation not being checked for success
--- a/tsf.h
+++ b/tsf.h
@@ -1344,8 +1344,12 @@
{
tsf* res;
if (!f) return TSF_NULL;
- if (!f->refCount)
- *(f->refCount = (int*)TSF_MALLOC(sizeof(int))) = 1;
+ if (!f->refCount) {
+ f->refCount = (int*)TSF_MALLOC(sizeof(int));
+ if (!f->refCount)
+ return TSF_NULL;
+ *f->refCount = 1;
+ }
res = (tsf*)TSF_MALLOC(sizeof(tsf));
if (!res) return TSF_NULL;
TSF_MEMCPY(res, f, sizeof(tsf));
@@ -1352,6 +1356,7 @@
res->voices = TSF_NULL;
res->voiceNum = 0;
res->channels = TSF_NULL;
+
++(*res->refCount);
return res;
}