NSData dataWithBytesNoCopy triggers guardMalloc when released
Please see update below
<s:element name="GetFile">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="User" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="Password" type="s:string />
<s:element minOccurs="0" maxOccurs="1" name="ObjectId" type="s:string"/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="GetFileResponse">
<s:complexType>
<s:sequence>
<!-- This is the return value -->
<s:element minOccurs="0" maxOccurs="1"
name="GetFileResult" type="s:base64Binary"/>
</s:sequence>
</s:complexType>
</s:element>
With the generated code from wsdl2objc开发者_运维问答 I get an error with guard malloc enabled:
GuardMalloc[eBridge-1115]: guard malloc zone failure: freeing a pointer we didn't allocate that was not claimed by any registered zone
GuardMalloc[eBridge-1115]: Explicitly trapping into debugger!!!
This is the last obj-c code i can see before it goes all asm on me:
@implementation WebServices_GetFileResponse
- (void)dealloc
{
[soapSigner release];
//breaks on the line below
if(GetFileResult != nil) [GetFileResult release];
[super dealloc];
}
I believe it is breaking in the generated Response object's deserializeElementsFromNode but have not pinpointed it yet. This is not a "Debug my program for me" question. My question is simply - Has anyone ran into this problem with a base64Binary byte array return type generated by wsdl2objc?
Update
The problem I believe lies in
+ (id)dateWithBase64EncodedString;
in NSData (MBBase64) -
char *data = malloc(...);
NSUInteger length = 0;
... // fill data[length++];
realloc(data, length);
return [NSData dataWithBytesNoCopy:bytes length:length]; //offending line?
Im making an assumption that this does not make the objective-c runtime claim the memory.. so when I am releasing the NSData it is somehow still allocated with 'malloc'. Does anyone know better than I do?
In + (id)dateWithBase64EncodedString I changed the last line to:
return [NSData dataWithBytesNoCopy:bytes length:length **freeWhenDone:NO**];
and it seemed to work. This is just my hack, but if you are the author of wsdl2objc sees this hopefully it will help.
精彩评论