-#define CONVERT_COM_STRING(s) G_STMT_START { CFStringRef _s = (CFStringRef)s; s = (char*) malloc(100); CFStringGetCString(_s, s, 100, kCFStringEncodingUTF8); CFRelease(_s); } G_STMT_END
+#define CONVERT_COM_STRING(s) G_STMT_START { \
+ CFStringRef _s = (CFStringRef)s; \
+ CFIndex _length; \
+ CFStringGetBytes(_s, CFRangeMake(0, CFStringGetLength(_s)), kCFStringEncodingUTF8, 0, FALSE, NULL, 0, &_length); \
+ _length += 1; \
+ s = (char *) malloc(_length); \
+ CFStringGetCString(_s, s, _length, kCFStringEncodingUTF8); \
+ CFRelease(_s); \
+ } G_STMT_END