@@ -31,11 +31,11 @@ #import "OFString.h" #import "OFExceptions.h" #import "macros.h" -#import "asprintf.h" +#import "of_asprintf.h" #import "unicode.h" @implementation OFMutableString - (void)_applyTable: (const of_unichar_t* const[])table withSize: (size_t)table_size @@ -230,25 +230,23 @@ - (void)appendFormat: (OFString*)fmt withArguments: (va_list)args { char *t; + int len; if (fmt == nil) @throw [OFInvalidArgumentException newWithClass: isa selector: _cmd]; - if ((vasprintf(&t, [fmt cString], args)) == -1) { - /* - * This is only the most likely error to happen. Unfortunately, - * there is no good way to check what really happened. - */ - @throw [OFOutOfMemoryException newWithClass: isa]; - } + if ((len = of_vasprintf(&t, [fmt cString], args)) == -1) + @throw [OFInvalidArgumentException newWithClass: isa + selector: _cmd]; @try { - [self appendCString: t]; + [self appendCString: t + withLength: len]; } @finally { free(t); } }