Project

General

Profile

« Previous | Next » 

Revision 30e6825e

Added by nobu (Nobuyoshi Nakada) over 10 years ago

tkutil.c: fix memory leak and segfault

  • ext/tk/tkutil/tkutil.c (cbsubst_append_inf_key): extract a
    function append a key in subst info to a string. make result
    strings first and get rid of potential memory leak.

  • ext/tk/tkutil/tkutil.c (cbsubst_get_subst_arg): allocate the
    result buffer as a string to fix:

    • memory leak when the argument key is not found:

      loop {Tk::Event.subst_arg(:a) rescue nil}

    • buffer overflow segfault when many arguments:

      class T < TkUtil::CallbackSubst
      _setup_subst_table([[?a, ?A, :_a]], [])
      subst_arg(*[:_a]*1000).size
      end

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50704 b2dd03c8-39d4-4d8f-98ff-823fe69b080e