+2013-10-09 Jan Djärv <jan.h.d@swipnet.se>
+
+ * nsfns.m (Fns_convert_utf8_nfd_to_nfc): Check input for valid UTF-8
+ or throw error (Bug#15570).
+
2013-10-09 Paul Eggert <eggert@cs.ucla.edu>
* intervals.c (temp_set_point_both): Move test into 'eassert',
/* TODO: If GNUstep ever implements precomposedStringWithCanonicalMapping,
remove this. */
NSString *utfStr;
- Lisp_Object ret;
+ Lisp_Object ret = Qnil;
+ NSAutoreleasePool *pool;
CHECK_STRING (str);
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
- utfStr = [NSString stringWithUTF8String: SSDATA (str)];
+ pool = [[NSAutoreleasePool alloc] init];
+ utfStr = [NSString stringWithUTF8String: SSDATA (str)];
#ifdef NS_IMPL_COCOA
- utfStr = [utfStr precomposedStringWithCanonicalMapping];
+ if (utfStr)
+ utfStr = [utfStr precomposedStringWithCanonicalMapping];
#endif
- ret = build_string ([utfStr UTF8String]);
+ if (utfStr)
+ {
+ const char *cstr = [utfStr UTF8String];
+ if (cstr)
+ ret = build_string (cstr);
+ }
+
[pool release];
+ if (NILP (ret))
+ error ("Invalid UTF-8");
+
return ret;
}