To: vim_dev@googlegroups.com Subject: Patch 9.0.0338 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 9.0.0338 Problem: Return value of list_append_list() not always checked. Solution: Check return value and handle failure. Files: src/evalwindow.c, src/evalfunc.c, src/list.c, src/search.c *** ../vim-9.0.0337/src/evalwindow.c 2022-08-30 19:48:17.202760217 +0100 --- src/evalwindow.c 2022-08-31 11:20:45.171029977 +0100 *************** *** 261,267 **** } /* ! * Get the layout of the given tab page for winlayout(). */ static void get_framelayout(frame_T *fr, list_T *l, int outer) --- 261,267 ---- } /* ! * Get the layout of the given tab page for winlayout() and add it to "l". */ static void get_framelayout(frame_T *fr, list_T *l, int outer) *************** *** 281,287 **** fr_list = list_alloc(); if (fr_list == NULL) return; ! list_append_list(l, fr_list); } if (fr->fr_layout == FR_LEAF) --- 281,291 ---- fr_list = list_alloc(); if (fr_list == NULL) return; ! if (list_append_list(l, fr_list) == FAIL) ! { ! vim_free(fr_list); ! return; ! } } if (fr->fr_layout == FR_LEAF) *************** *** 300,306 **** win_list = list_alloc(); if (win_list == NULL) return; ! list_append_list(fr_list, win_list); child = fr->fr_child; while (child != NULL) { --- 304,315 ---- win_list = list_alloc(); if (win_list == NULL) return; ! if (list_append_list(fr_list, win_list) == FAIL) ! { ! vim_free(win_list); ! return; ! } ! child = fr->fr_child; while (child != NULL) { *** ../vim-9.0.0337/src/evalfunc.c 2022-08-30 19:48:17.202760217 +0100 --- src/evalfunc.c 2022-08-31 11:20:25.398933060 +0100 *************** *** 4811,4819 **** l = list_alloc(); if (l == NULL) return; - if (list_append_list(rettv->vval.v_list, l) == FAIL) return; /* * The current window change list index tracks only the position for the * current buffer. For other buffers use the stored index for the current --- 4811,4822 ---- l = list_alloc(); if (l == NULL) return; if (list_append_list(rettv->vval.v_list, l) == FAIL) + { + vim_free(l); return; + } + /* * The current window change list index tracks only the position for the * current buffer. For other buffers use the stored index for the current *************** *** 5045,5053 **** l = list_alloc(); if (l == NULL) return; - if (list_append_list(rettv->vval.v_list, l) == FAIL) return; list_append_number(rettv->vval.v_list, (varnumber_T)wp->w_jumplistidx); for (i = 0; i < wp->w_jumplistlen; ++i) --- 5048,5059 ---- l = list_alloc(); if (l == NULL) return; if (list_append_list(rettv->vval.v_list, l) == FAIL) + { + vim_free(l); return; + } + list_append_number(rettv->vval.v_list, (varnumber_T)wp->w_jumplistidx); for (i = 0; i < wp->w_jumplistlen; ++i) *** ../vim-9.0.0337/src/list.c 2022-08-30 19:48:17.202760217 +0100 --- src/list.c 2022-08-31 11:21:45.459302935 +0100 *************** *** 1076,1083 **** if (l2 == NULL) break; ! if (list_append_list(rettv->vval.v_list, l2) == FAIL ! || list_append_number(l2, idx) == FAIL || list_append_tv(l2, &li->li_tv) == FAIL) break; } --- 1076,1087 ---- if (l2 == NULL) break; ! if (list_append_list(rettv->vval.v_list, l2) == FAIL) ! { ! vim_free(l2); ! break; ! } ! if (list_append_number(l2, idx) == FAIL || list_append_tv(l2, &li->li_tv) == FAIL) break; } *************** *** 1108,1115 **** l2 = list_alloc(); if (l2 == NULL) break; ! if (list_append_list(rettv->vval.v_list, l2) == FAIL ! || list_append_number(l2, idx) == FAIL || list_append_string(l2, p, len) == FAIL) break; p += len; --- 1112,1123 ---- l2 = list_alloc(); if (l2 == NULL) break; ! if (list_append_list(rettv->vval.v_list, l2) == FAIL) ! { ! vim_free(l2); ! break; ! } ! if (list_append_number(l2, idx) == FAIL || list_append_string(l2, p, len) == FAIL) break; p += len; *** ../vim-9.0.0337/src/search.c 2022-08-30 19:48:17.202760217 +0100 --- src/search.c 2022-08-31 11:23:30.671706952 +0100 *************** *** 4748,4755 **** if (items[i].score == SCORE_NONE) break; if (items[i].lmatchpos != NULL ! && list_append_list(retlist, items[i].lmatchpos) ! == FAIL) goto done; } --- 4748,4754 ---- if (items[i].score == SCORE_NONE) break; if (items[i].lmatchpos != NULL ! && list_append_list(retlist, items[i].lmatchpos) == FAIL) goto done; } *************** *** 4869,4885 **** --- 4868,4893 ---- if (l == NULL) goto done; if (list_append_list(rettv->vval.v_list, l) == FAIL) + { + vim_free(l); goto done; + } l = list_alloc(); if (l == NULL) goto done; if (list_append_list(rettv->vval.v_list, l) == FAIL) + { + vim_free(l); goto done; + } l = list_alloc(); if (l == NULL) goto done; if (list_append_list(rettv->vval.v_list, l) == FAIL) + { + vim_free(l); goto done; + } } fuzzy_match_in_list(argvars[0].vval.v_list, tv_get_string(&argvars[1]), *** ../vim-9.0.0337/src/version.c 2022-08-30 22:24:20.048441013 +0100 --- src/version.c 2022-08-31 11:16:59.405659919 +0100 *************** *** 709,710 **** --- 709,712 ---- { /* Add new patch number below this line */ + /**/ + 338, /**/ -- LARGE MAN: Who's that then? CART DRIVER: (Grudgingly) I dunno, Must be a king. LARGE MAN: Why? CART DRIVER: He hasn't got shit all over him. "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD /// Bram Moolenaar -- Bram@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 ///