[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Help-smalltalk] [PATCH] libgst: Fix crash with new GNU toolchains on po

From: Holger Hans Peter Freyther
Subject: [Help-smalltalk] [PATCH] libgst: Fix crash with new GNU toolchains on
Date: Sat, 30 Nov 2013 19:06:02 +0100

A compile time constant is being compiled outside of a class. At the
same time currentClass has been casted to a class. This means that some
random memory has been accessed. For compile time constants check if
the current class isNil (e.g. during an eval) and then start to use
"nil class class" which should be equivalent to "nil class asMetaclass".

2013-11-30  Holger Hans Peter Freyther  <address@hidden>

        * gst-parse.c: Check if currentClass is nil before calling
 libgst/gst-parse.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/libgst/gst-parse.c b/libgst/gst-parse.c
index 232e172..bd551d8 100644
--- a/libgst/gst-parse.c
+++ b/libgst/gst-parse.c
@@ -1948,6 +1948,7 @@ static tree_node
 parse_compile_time_constant (gst_parser *p)
   tree_node temps, statements;
+  OOP currentClass;
   YYLTYPE location = *loc(p,0);
   assert (token (p, 0) == '#');
@@ -1960,9 +1961,14 @@ parse_compile_time_constant (gst_parser *p)
   if (!statements || _gst_had_error)
     return _gst_make_oop_constant (&location, _gst_nil_oop);
+  /* This can happen when parsing an Eval statement */
+  currentClass = _gst_current_parser->currentClass;
+  if (IS_NIL(_gst_current_parser->currentClass))
+    currentClass = OOP_CLASS(_gst_undefined_object_class);
   return _gst_make_method (&location, loc(p, 0),
                            NULL, temps, NULL, statements, NULL,
-                           _gst_current_parser->currentClass,
+                           currentClass,

reply via email to

[Prev in Thread] Current Thread [Next in Thread]