Mercurial > vim
comparison src/if_py_both.h @ 4633:3857d399ab41 v7.3.1064
updated for version 7.3.1064
Problem: Python: insufficient error checking.
Solution: Python patch 23. (ZyX)
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Thu, 30 May 2013 13:17:17 +0200 |
parents | 4157fef7b950 |
children | 07c534fe9b6c |
comparison
equal
deleted
inserted
replaced
4632:f2ecc8759d6e | 4633:3857d399ab41 |
---|---|
3302 } | 3302 } |
3303 } | 3303 } |
3304 | 3304 |
3305 for (i = 0; i < new_len; ++i) | 3305 for (i = 0; i < new_len; ++i) |
3306 { | 3306 { |
3307 PyObject *line = PyList_GetItem(list, i); | 3307 PyObject *line; |
3308 | 3308 |
3309 array[i] = StringToLine(line); | 3309 if (!(line = PyList_GetItem(list, i)) || |
3310 if (array[i] == NULL) | 3310 !(array[i] = StringToLine(line))) |
3311 { | 3311 { |
3312 while (i) | 3312 while (i) |
3313 vim_free(array[--i]); | 3313 vim_free(array[--i]); |
3314 PyMem_Free(array); | 3314 PyMem_Free(array); |
3315 return FAIL; | 3315 return FAIL; |
3317 } | 3317 } |
3318 | 3318 |
3319 VimTryStart(); | 3319 VimTryStart(); |
3320 PyErr_Clear(); | 3320 PyErr_Clear(); |
3321 | 3321 |
3322 // START of region without "return". Must call restore_buffer()! | 3322 /* START of region without "return". Must call restore_buffer()! */ |
3323 switch_buffer(&savebuf, buf); | 3323 switch_buffer(&savebuf, buf); |
3324 | 3324 |
3325 if (u_save((linenr_T)(lo-1), (linenr_T)hi) == FAIL) | 3325 if (u_save((linenr_T)(lo-1), (linenr_T)hi) == FAIL) |
3326 PyErr_SetVim(_("cannot save undo information")); | 3326 PyErr_SetVim(_("cannot save undo information")); |
3327 | 3327 |
3398 changed_lines((linenr_T)lo, 0, (linenr_T)hi, (long)extra); | 3398 changed_lines((linenr_T)lo, 0, (linenr_T)hi, (long)extra); |
3399 | 3399 |
3400 if (buf == savebuf) | 3400 if (buf == savebuf) |
3401 py_fix_cursor((linenr_T)lo, (linenr_T)hi, (linenr_T)extra); | 3401 py_fix_cursor((linenr_T)lo, (linenr_T)hi, (linenr_T)extra); |
3402 | 3402 |
3403 // END of region without "return". | 3403 /* END of region without "return". */ |
3404 restore_buffer(savebuf); | 3404 restore_buffer(savebuf); |
3405 | 3405 |
3406 if (VimTryEnd()) | 3406 if (VimTryEnd()) |
3407 return FAIL; | 3407 return FAIL; |
3408 | 3408 |
3477 return FAIL; | 3477 return FAIL; |
3478 } | 3478 } |
3479 | 3479 |
3480 for (i = 0; i < size; ++i) | 3480 for (i = 0; i < size; ++i) |
3481 { | 3481 { |
3482 PyObject *line = PyList_GetItem(lines, i); | 3482 PyObject *line; |
3483 array[i] = StringToLine(line); | 3483 |
3484 | 3484 if (!(line = PyList_GetItem(lines, i)) || |
3485 if (array[i] == NULL) | 3485 !(array[i] = StringToLine(line))) |
3486 { | 3486 { |
3487 while (i) | 3487 while (i) |
3488 vim_free(array[--i]); | 3488 vim_free(array[--i]); |
3489 PyMem_Free(array); | 3489 PyMem_Free(array); |
3490 return FAIL; | 3490 return FAIL; |
4012 if (CheckBuffer(self)) | 4012 if (CheckBuffer(self)) |
4013 return NULL; | 4013 return NULL; |
4014 | 4014 |
4015 if (!PyArg_ParseTuple(args, "s", &pmark)) | 4015 if (!PyArg_ParseTuple(args, "s", &pmark)) |
4016 return NULL; | 4016 return NULL; |
4017 | |
4018 if (STRLEN(pmark) != 1) | |
4019 { | |
4020 PyErr_SetString(PyExc_ValueError, | |
4021 _("mark name must be a single character")); | |
4022 return NULL; | |
4023 } | |
4024 | |
4017 mark = *pmark; | 4025 mark = *pmark; |
4018 | |
4019 VimTryStart(); | 4026 VimTryStart(); |
4020 switch_buffer(&savebuf, self->buf); | 4027 switch_buffer(&savebuf, self->buf); |
4021 posp = getmark(mark, FALSE); | 4028 posp = getmark(mark, FALSE); |
4022 restore_buffer(savebuf); | 4029 restore_buffer(savebuf); |
4023 if (VimTryEnd()) | 4030 if (VimTryEnd()) |
4256 { | 4263 { |
4257 int count; | 4264 int count; |
4258 | 4265 |
4259 if (value->ob_type != &BufferType) | 4266 if (value->ob_type != &BufferType) |
4260 { | 4267 { |
4261 PyErr_SetString(PyExc_TypeError, _("expected vim.buffer object")); | 4268 PyErr_SetString(PyExc_TypeError, _("expected vim.Buffer object")); |
4262 return -1; | 4269 return -1; |
4263 } | 4270 } |
4264 | 4271 |
4265 if (CheckBuffer((BufferObject *)(value))) | 4272 if (CheckBuffer((BufferObject *)(value))) |
4266 return -1; | 4273 return -1; |
4281 { | 4288 { |
4282 int count; | 4289 int count; |
4283 | 4290 |
4284 if (value->ob_type != &WindowType) | 4291 if (value->ob_type != &WindowType) |
4285 { | 4292 { |
4286 PyErr_SetString(PyExc_TypeError, _("expected vim.window object")); | 4293 PyErr_SetString(PyExc_TypeError, _("expected vim.Window object")); |
4287 return -1; | 4294 return -1; |
4288 } | 4295 } |
4289 | 4296 |
4290 if (CheckWindow((WindowObject *)(value))) | 4297 if (CheckWindow((WindowObject *)(value))) |
4291 return -1; | 4298 return -1; |
4313 } | 4320 } |
4314 else if (strcmp(name, "tabpage") == 0) | 4321 else if (strcmp(name, "tabpage") == 0) |
4315 { | 4322 { |
4316 if (value->ob_type != &TabPageType) | 4323 if (value->ob_type != &TabPageType) |
4317 { | 4324 { |
4318 PyErr_SetString(PyExc_TypeError, _("expected vim.tabpage object")); | 4325 PyErr_SetString(PyExc_TypeError, _("expected vim.TabPage object")); |
4319 return -1; | 4326 return -1; |
4320 } | 4327 } |
4321 | 4328 |
4322 if (CheckTabPage((TabPageObject *)(value))) | 4329 if (CheckTabPage((TabPageObject *)(value))) |
4323 return -1; | 4330 return -1; |