ソースを参照

fix safari crash with shift key

David Rose 16 年 前
コミット
e775c9f307
1 ファイル変更10 行追加7 行削除
  1. 10 7
      direct/src/plugin_npapi/ppInstance.cxx

+ 10 - 7
direct/src/plugin_npapi/ppInstance.cxx

@@ -1992,14 +1992,17 @@ copy_cocoa_event(P3DCocoaEvent *p3d_event, NPCocoaEvent *np_event,
 ////////////////////////////////////////////////////////////////////
 const wchar_t *PPInstance::
 make_ansi_string(wstring &result, NPNSString *ns_string) {
-  // An NPNSString is really just an NSString, which is itself just a
-  // CFString.
-  CFStringRef cfstr = (CFStringRef)ns_string;
-  CFIndex length = CFStringGetLength(cfstr);
-
   result.clear();
-  for (CFIndex i = 0; i < length; ++i) {
-    result += (wchar_t)CFStringGetCharacterAtIndex(cfstr, i);
+  
+  if (ns_string != NULL) {
+    // An NPNSString is really just an NSString, which is itself just a
+    // CFString.
+    CFStringRef cfstr = (CFStringRef)ns_string;
+    CFIndex length = CFStringGetLength(cfstr);
+    
+    for (CFIndex i = 0; i < length; ++i) {
+      result += (wchar_t)CFStringGetCharacterAtIndex(cfstr, i);
+    }
   }
 
   return result.c_str();