Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Feeding NSUnarchiver bad data can cause crash



Jeremy,

Check out the section on "Handling Exceptions" in the Cocoa doc. NS_DURING,
NS_HANDLER, and NS_ENDHANDLER are your friend ;^}

see
<http://developer.apple.com/documentation/Cocoa/Conceptual/Exceptions/Tasks/
HandlingExceptions.html>

later,

douglas

on 6/2/04 12:44 PM, Jeremy Dronfield at email@hidden wrote:

> If you provide NSUnarchiver with data which is not unarchivable, an
> error results. Using the class method +unarchiveObjectWithData: with
> bad data produces a warning:
>
> *** +[NSUnarchiver unarchiveObjectWithData:]: extra data discarded
>
> Sometimes - maybe about 1 in 100 - this causes a crash. Using the
> designated initializer, -initForReadingWithData: followed by
> -decodeObject does not produce a warning, but does produce a crash with
> about the same frequency, described as
>
> *** malloc_zone_malloc[414]: argument too large: 4294967286
>
> Obviously, the solution is not to feed NSUnarchiver bad data. But given
> that bad data happens, and a crash can result, why isn't there a method
> like -[NSData canBeUnarchived] for use in situations where bad data
> might be a risk? Does anyone know of a workaround which could provide a
> comparable check?
>
> Regards,
> -Jeremy
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


References: 
 >Feeding NSUnarchiver bad data can cause crash (From: Jeremy Dronfield <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.