Vim crashes with SEGV when executing :py vim.bindeval("matchstr('', 'x')").
And vim.eval("matchstr('', 'x')") returns None.

The following patch fix this problem.
Please check it.


diff -r 61a7c3f01088 src/if_py_both.h
--- a/src/if_py_both.h  Wed Oct 03 21:48:44 2012 +0200
+++ b/src/if_py_both.h  Thu Oct 04 20:44:08 2012 +0900
@@ -351,7 +351,10 @@

     if (our_tv->v_type == VAR_STRING)
     {
-       result = Py_BuildValue("s", our_tv->vval.v_string);
+       if (our_tv->vval.v_string == NULL)
+           result = Py_BuildValue("s", "");
+       else
+           result = Py_BuildValue("s", our_tv->vval.v_string);
     }
     else if (our_tv->v_type == VAR_NUMBER)
     {
@@ -2751,7 +2754,10 @@
     switch (tv->v_type)
     {
        case VAR_STRING:
-           return PyBytes_FromString((char *) tv->vval.v_string);
+           if (tv->vval.v_string == NULL)
+               return PyBytes_FromString("");
+           else
+               return PyBytes_FromString((char *) tv->vval.v_string);
        case VAR_NUMBER:
            return PyLong_FromLong((long) tv->vval.v_number);
 #ifdef FEAT_FLOAT


-- 
Yukihiro Nakadaira - [email protected]

-- 
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

Raspunde prin e-mail lui