Permalink
Browse files

ns-do-applescript: protect source code string from garbage collection

As an attempt to fix the crash in ns_do_applescript (TTermEntry::NextSubTerm).
The reasoning here is that the NSString used to construct the AppleScript object
is sufficiently protected from Cocoa's/ObjC GC.  So, perhaps the NS run loop called up
in ns-do-applescript causes Emacs/Lisp to be executed via some callbacks, and its GC.
(This may be a bug in itself.)
  • Loading branch information...
1 parent 0dd9193 commit a7252e4be7cc22c4702ebd6c2c9ac9d8c53de535 @davidswelt committed Jan 13, 2012
Showing with 6 additions and 0 deletions.
  1. +6 −0 src/nsfns.m
View
@@ -2673,6 +2673,8 @@ and GNUstep implementations ("distributor-specific release
(script)
Lisp_Object script;
{
+ struct gcpro gcpro1;
+
Lisp_Object result;
long status;
NSEvent *nxev;
@@ -2681,6 +2683,7 @@ and GNUstep implementations ("distributor-specific release
check_ns ();
BLOCK_INPUT;
+ GCPRO1 (script);
as_script = script;
as_result = &result;
@@ -2706,7 +2709,10 @@ and GNUstep implementations ("distributor-specific release
as_status = 0;
as_script = Qnil;
as_result = 0;
+
+ UNGCPRO;
UNBLOCK_INPUT;
+
if (status == 0)
return result;
else if (!STRINGP (result))

0 comments on commit a7252e4

Please sign in to comment.