sanshelly / wsdl2objc

Automatically exported from code.google.com/p/wsdl2objc
MIT License
0 stars 0 forks source link

Empty date values #52

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What version of the product are you using? On what operating system?
Running revision 147 from subversion on an iPhone 3GS.

What steps will reproduce the problem?
1. Send a request to get some data from the server
2. Recieve a SOAP response with a date element that's empty like this:
<Pda_deleted xsi:nil="true" />

What is the expected output?
An (pda) object with all properties filled and the NSDate Pda_deleted property 
being nil.

What do you see instead?
An EXC_BAD_ACCESS error in the NSData+ISO8601Parser.m file.

What is happening?
The dateWithString:strictly:timeSeparator:getRange: method is casting the empty 
NSString to a 
const unsigned char *. After that it tries to get the length and the 
application crashes.

Code snipped (str == nil):
  const unsigned char *ch = (const unsigned char *)[str UTF8String]; <-- Typecast

  NSRange range = { 0U, 0U };
  const unsigned char *start_of_date;
  if(strict && isspace(*ch)) {
    range.location = NSNotFound;
    isValidDate = NO;
  } else {
    //Skip leading whitespace.
    unsigned i = 0U;
    unsigned len = strlen((const char *)ch); <-- Crash
    for(; i < len; ++i) {
      if(!isspace(ch[i]))
        break;
    }

How do we QuickFix this?
I added the following code at the first line of the method right before the 
NSCalender 
initialization:

    if (str == nil)
    {
        return nil;
    }

Original issue reported on code.google.com by mkad...@gmail.com on 21 Oct 2009 at 1:58

GoogleCodeExporter commented 8 years ago
Temporally solved this problem, by adding

if (str == nil) return nil;

to the

+ (NSDate *)dateWithString:(NSString *)str strictly:(BOOL)strict 
timeSeparator:(unichar)timeSep getRange:(out NSRange *)outRange

method

Original comment by ReznikSA on 24 Sep 2010 at 12:47

GoogleCodeExporter commented 8 years ago
Fixed as requested in revision 184.

Original comment by hasse...@gmail.com on 28 Feb 2011 at 10:05

GoogleCodeExporter commented 8 years ago
Issue 122 has been merged into this issue.

Original comment by hasse...@gmail.com on 28 Feb 2011 at 10:09