Mercurial > vim
comparison src/if_py_both.h @ 3852:0f5ee2629635 v7.3.683
updated for version 7.3.683
Problem: ":python" may crash when vimbindeval() returns None.
Solution: Check for v_string to be NULL. (Yukihiro Nakadaira)
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Fri, 05 Oct 2012 21:30:07 +0200 |
parents | fd6ef931aa77 |
children | 3e22fe67fa69 |
comparison
equal
deleted
inserted
replaced
3851:c3791ff631ea | 3852:0f5ee2629635 |
---|---|
349 } | 349 } |
350 } | 350 } |
351 | 351 |
352 if (our_tv->v_type == VAR_STRING) | 352 if (our_tv->v_type == VAR_STRING) |
353 { | 353 { |
354 result = Py_BuildValue("s", our_tv->vval.v_string); | 354 result = Py_BuildValue("s", our_tv->vval.v_string == NULL |
355 ? "" : (char *)our_tv->vval.v_string); | |
355 } | 356 } |
356 else if (our_tv->v_type == VAR_NUMBER) | 357 else if (our_tv->v_type == VAR_NUMBER) |
357 { | 358 { |
358 char buf[NUMBUFLEN]; | 359 char buf[NUMBUFLEN]; |
359 | 360 |
2749 return NULL; | 2750 return NULL; |
2750 } | 2751 } |
2751 switch (tv->v_type) | 2752 switch (tv->v_type) |
2752 { | 2753 { |
2753 case VAR_STRING: | 2754 case VAR_STRING: |
2754 return PyBytes_FromString((char *) tv->vval.v_string); | 2755 return PyBytes_FromString(tv->vval.v_string == NULL |
2756 ? "" : (char *)tv->vval.v_string); | |
2755 case VAR_NUMBER: | 2757 case VAR_NUMBER: |
2756 return PyLong_FromLong((long) tv->vval.v_number); | 2758 return PyLong_FromLong((long) tv->vval.v_number); |
2757 #ifdef FEAT_FLOAT | 2759 #ifdef FEAT_FLOAT |
2758 case VAR_FLOAT: | 2760 case VAR_FLOAT: |
2759 return PyFloat_FromDouble((double) tv->vval.v_float); | 2761 return PyFloat_FromDouble((double) tv->vval.v_float); |
2761 case VAR_LIST: | 2763 case VAR_LIST: |
2762 return ListNew(tv->vval.v_list); | 2764 return ListNew(tv->vval.v_list); |
2763 case VAR_DICT: | 2765 case VAR_DICT: |
2764 return DictionaryNew(tv->vval.v_dict); | 2766 return DictionaryNew(tv->vval.v_dict); |
2765 case VAR_FUNC: | 2767 case VAR_FUNC: |
2766 return FunctionNew(tv->vval.v_string); | 2768 return FunctionNew(tv->vval.v_string == NULL |
2769 ? (char_u *)"" : tv->vval.v_string); | |
2767 case VAR_UNKNOWN: | 2770 case VAR_UNKNOWN: |
2768 Py_INCREF(Py_None); | 2771 Py_INCREF(Py_None); |
2769 return Py_None; | 2772 return Py_None; |
2770 default: | 2773 default: |
2771 PyErr_SetVim(_("internal error: invalid value type")); | 2774 PyErr_SetVim(_("internal error: invalid value type")); |