Patch 9.0.1095
Problem:    Using freed memory when declaration fails. (Yegappan Lakshmanan)
Solution:   After unreferencing an object set the reference to NULL.
Files:      src/typval.c, src/testdir/test_vim9_class.vim


*** ../vim-9.0.1094/src/typval.c        2022-12-08 20:41:55.433288306 +0000
--- src/typval.c        2022-12-25 19:08:23.690457433 +0000
***************
*** 162,170 ****
--- 162,172 ----
                break;
            case VAR_CLASS:
                class_unref(varp->vval.v_class);
+               varp->vval.v_class = NULL;
                break;
            case VAR_OBJECT:
                object_unref(varp->vval.v_object);
+               varp->vval.v_object = NULL;
                break;
            case VAR_UNKNOWN:
            case VAR_ANY:
*** ../vim-9.0.1094/src/testdir/test_vim9_class.vim     2022-12-24 
21:23:59.578929527 +0000
--- src/testdir/test_vim9_class.vim     2022-12-25 19:19:14.751363987 +0000
***************
*** 349,354 ****
--- 349,370 ----
        assert_equal('make = 123', c2.GetMake())
    END
    v9.CheckScriptSuccess(lines)
+ 
+   lines =<< trim END
+       vim9script
+ 
+       class MyCar
+         this.make: string
+ 
+         def new(make_arg: string)
+             this.make = make_arg
+         enddef
+       endclass
+ 
+       var c = MyCar.new("abc")
+       var c = MyCar.new("def")
+   END
+   v9.CheckScriptFailure(lines, 'E1041:')
  enddef
  
  def Test_class_member_access()
*** ../vim-9.0.1094/src/version.c       2022-12-25 15:59:19.993863341 +0000
--- src/version.c       2022-12-25 19:15:39.088185105 +0000
***************
*** 697,698 ****
--- 697,700 ----
  {   /* Add new patch number below this line */
+ /**/
+     1095,
  /**/

-- 
ARTHUR: Listen, old crone!  Unless you tell us where we can buy a shrubbery,
        my friend and I will ... we will say "Ni!"
CRONE:  Do your worst!
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

 /// Bram Moolenaar -- b...@moolenaar.net -- http://www.Moolenaar.net   \\\
///                                                                      \\\
\\\        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/20221225193250.475A91C0AA3%40moolenaar.net.

Raspunde prin e-mail lui