Mercurial > vim
comparison src/alloc.c @ 30100:84c18beec6bc v9.0.0386
patch 9.0.0386: some code blocks are nested too deep
Commit: https://github.com/vim/vim/commit/b1f471ee20b0fa783ecd6e29aa69067e6c821376
Author: Yegappan Lakshmanan <yegappan@yahoo.com>
Date: Mon Sep 5 14:33:47 2022 +0100
patch 9.0.0386: some code blocks are nested too deep
Problem: Some code blocks are nested too deep.
Solution: Bail out earlier. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/11058)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 05 Sep 2022 15:45:03 +0200 |
parents | 31c598083364 |
children | d7066cbac096 |
comparison
equal
deleted
inserted
replaced
30099:f1eed0cd1207 | 30100:84c18beec6bc |
---|---|
85 | 85 |
86 printf("\r\n"); | 86 printf("\r\n"); |
87 j = 0; | 87 j = 0; |
88 for (i = 0; i < MEM_SIZES - 1; i++) | 88 for (i = 0; i < MEM_SIZES - 1; i++) |
89 { | 89 { |
90 if (mem_allocs[i] || mem_frees[i]) | 90 if (mem_allocs[i] == 0 && mem_frees[i] == 0) |
91 continue; | |
92 | |
93 if (mem_frees[i] > mem_allocs[i]) | |
94 printf("\r\n%s", _("ERROR: ")); | |
95 printf("[%4d / %4lu-%-4lu] ", i + 1, mem_allocs[i], mem_frees[i]); | |
96 j++; | |
97 if (j > 3) | |
91 { | 98 { |
92 if (mem_frees[i] > mem_allocs[i]) | 99 j = 0; |
93 printf("\r\n%s", _("ERROR: ")); | 100 printf("\r\n"); |
94 printf("[%4d / %4lu-%-4lu] ", i + 1, mem_allocs[i], mem_frees[i]); | |
95 j++; | |
96 if (j > 3) | |
97 { | |
98 j = 0; | |
99 printf("\r\n"); | |
100 } | |
101 } | 101 } |
102 } | 102 } |
103 | 103 |
104 i = MEM_SIZES - 1; | 104 i = MEM_SIZES - 1; |
105 if (mem_allocs[i]) | 105 if (mem_allocs[i]) |
330 * Did_outofmem_msg is reset when a character is read. | 330 * Did_outofmem_msg is reset when a character is read. |
331 */ | 331 */ |
332 void | 332 void |
333 do_outofmem_msg(size_t size) | 333 do_outofmem_msg(size_t size) |
334 { | 334 { |
335 if (!did_outofmem_msg) | 335 if (did_outofmem_msg) |
336 { | 336 return; |
337 // Don't hide this message | 337 |
338 emsg_silent = 0; | 338 // Don't hide this message |
339 | 339 emsg_silent = 0; |
340 // Must come first to avoid coming back here when printing the error | 340 |
341 // message fails, e.g. when setting v:errmsg. | 341 // Must come first to avoid coming back here when printing the error |
342 did_outofmem_msg = TRUE; | 342 // message fails, e.g. when setting v:errmsg. |
343 | 343 did_outofmem_msg = TRUE; |
344 semsg(_(e_out_of_memory_allocating_nr_bytes), (long_u)size); | 344 |
345 | 345 semsg(_(e_out_of_memory_allocating_nr_bytes), (long_u)size); |
346 if (starting == NO_SCREEN) | 346 |
347 // Not even finished with initializations and already out of | 347 if (starting == NO_SCREEN) |
348 // memory? Then nothing is going to work, exit. | 348 // Not even finished with initializations and already out of |
349 mch_exit(123); | 349 // memory? Then nothing is going to work, exit. |
350 } | 350 mch_exit(123); |
351 } | 351 } |
352 | 352 |
353 #if defined(EXITFREE) || defined(PROTO) | 353 #if defined(EXITFREE) || defined(PROTO) |
354 | 354 |
355 /* | 355 /* |
778 | 778 |
779 for (i = 0; i < gap->ga_len; ++i) | 779 for (i = 0; i < gap->ga_len; ++i) |
780 len += (int)STRLEN(((char_u **)(gap->ga_data))[i]) + sep_len; | 780 len += (int)STRLEN(((char_u **)(gap->ga_data))[i]) + sep_len; |
781 | 781 |
782 s = alloc(len + 1); | 782 s = alloc(len + 1); |
783 if (s != NULL) | 783 if (s == NULL) |
784 { | 784 return NULL; |
785 *s = NUL; | 785 |
786 p = s; | 786 *s = NUL; |
787 for (i = 0; i < gap->ga_len; ++i) | 787 p = s; |
788 for (i = 0; i < gap->ga_len; ++i) | |
789 { | |
790 if (p != s) | |
788 { | 791 { |
789 if (p != s) | 792 STRCPY(p, sep); |
790 { | 793 p += sep_len; |
791 STRCPY(p, sep); | |
792 p += sep_len; | |
793 } | |
794 STRCPY(p, ((char_u **)(gap->ga_data))[i]); | |
795 p += STRLEN(p); | |
796 } | 794 } |
795 STRCPY(p, ((char_u **)(gap->ga_data))[i]); | |
796 p += STRLEN(p); | |
797 } | 797 } |
798 return s; | 798 return s; |
799 } | 799 } |
800 | 800 |
801 /* | 801 /* |