SecTransformAttributeRef search_for = pthread_getspecific(ah_search_key_slot);
if (!search_for)
{
- search_for = makeAH((transform_attribute*)malloc(sizeof(transform_attribute)));
+ transform_attribute* ta = (transform_attribute*)malloc(sizeof(transform_attribute));
+ search_for = makeAH(ta);
if (!search_for)
{
+ free(ta);
return NULL;
}
ah = makeAH(ta);
if (!ah)
{
+ free(ta);
return NULL;
}
ta->name = CFStringCreateCopy(NULL, label);
if (!ta->name)
{
+ CFRelease(ah);
free(ta);
return NULL;
}
{
CFReleaseNull(ta->name);
free(ta);
+ CFRelease(ah);
return NULL;
}
{
// make an array big enough to hold all of the attributes
CFIndex numAttributes = CFSetGetCount(mAttributes);
- transform_attribute* attributes[numAttributes];
+ transform_attribute **attributes = (transform_attribute**)malloc(numAttributes*sizeof(transform_attribute*));
+
+ if (attributes == NULL) {
+ // No more memory, we assume it's orphaned
+ return true;
+ }
TAGetAll(attributes);
{
if (attributes[i]->connections && CFArrayGetCount(attributes[i]->connections) != 0)
{
+ free(attributes);
return false;
}
}
+ free(attributes);
+
return true;
}
{
// make an array big enough to hold all of the attributes
CFIndex numAttributes = CFSetGetCount(mAttributes);
- transform_attribute* attributes[numAttributes];
+ transform_attribute **attributes = (transform_attribute**)malloc(numAttributes*sizeof(transform_attribute*));
+
+ if (attributes == NULL) {
+ // No more memory, we assume it's orphaned
+ return true;
+ }
TAGetAll(attributes);
{
if (attributes[i]->has_incoming_connection)
{
+ free(attributes);
return false;
}
}
+ free(attributes);
+
return true;
}
void Transform::FinalizeForClang()
{
CFIndex numAttributes = CFSetGetCount(mAttributes);
- SecTransformAttributeRef handles[numAttributes];
- CFSetGetValues(mAttributes, (const void**)&handles);
+ SecTransformAttributeRef *handles = (const void**)malloc(numAttributes*sizeof(SecTransformAttributeRef));
+
+ if (handles == NULL) {
+ syslog(LOG_ERR, "Unable to allocate SecTransformAttributeRef handles in FinalizeForClang");
+ return;
+ }
+
+ CFSetGetValues(mAttributes, handles);
for(CFIndex i = 0; i < numAttributes; ++i) {
SecTransformAttributeRef ah = handles[i];
}
dispatch_release(ta->q);
}
-
+
// We might be finalizing a transform as it is being activated, make sure that is complete before we do the rest
dispatch_group_notify(mActivationPending, mDispatchQueue, ^{
if (mActivationQueue != NULL) {
});
dispatch_release(mDispatchQueue);
});
+
+ free(handles);
}
void Transform::Finalize()
CFDictionaryRef Transform::CopyState()
{
CFIndex i, j, cnt = CFSetGetCount(mAttributes);
- transform_attribute *attrs[cnt];
- CFStringRef names[cnt];
- CFDictionaryRef values[cnt];
+ transform_attribute **attrs = (transform_attribute**)malloc(cnt*sizeof(transform_attribute*));
+ CFStringRef *names = (CFStringRef*)malloc(cnt*sizeof(CFStringRef));
+ CFDictionaryRef *values = (CFDictionaryRef*)malloc(sizeof(CFDictionaryRef) * cnt);
+
+ if (attrs == NULL || names == NULL || values == NULL) {
+ free(attrs);
+ free(names);
+ free(values);
+ return NULL;
+ }
+
TAGetAll(attrs);
for(i = j = 0; i < cnt; ++i)
{
}
CFDictionaryRef result = CFDictionaryCreate(NULL, (const void**)&names, (const void**)&values, j, &kCFCopyStringDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
-
+
+ free(names);
+
for(i = j = 0; i < cnt; ++i)
{
transform_attribute *ta = attrs[i];
}
}
+ free(attrs);
+ free(values);
return result;
}
// now walk the attribute list
CFIndex numAttributes = CFSetGetCount(mAttributes);
- transform_attribute *attributes[numAttributes];
+ transform_attribute **attributes = (transform_attribute**)malloc(numAttributes*sizeof(transform_attribute*));
+
+ if (attributes == NULL) {
+ return GetNoMemoryErrorAndRetain();
+ }
+
TAGetAll(attributes);
CFIndex i;
}
}
+ free(attributes);
+
return NULL;
}