Mercurial > vim
annotate src/nbdebug.h @ 19057:463b6fad54e9 v8.2.0089
patch 8.2.0089: crash when running out of memory in :setfiletype completion
Commit: https://github.com/vim/vim/commit/f0f8055102c264b1d0c0a79bf742dc126fb447b9
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Jan 5 22:05:49 2020 +0100
patch 8.2.0089: crash when running out of memory in :setfiletype completion
Problem: Crash when running out of memory in :setfiletype completion.
Solution: Do not allocate memory. (Dominique Pelle, closes https://github.com/vim/vim/issues/5438)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 05 Jan 2020 22:15:33 +0100 |
parents | 6e3dc2d630c2 |
children | 038eb6d9003a |
rev | line source |
---|---|
10042
4aead6a9b7a9
commit https://github.com/vim/vim/commit/edf3f97ae2af024708ebb4ac614227327033ca47
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
1 /* vi:set ts=8 sw=8 noet: |
7 | 2 * |
3 * VIM - Vi IMproved by Bram Moolenaar | |
4 * Visual Workshop integration by Gordon Prieur | |
5 * | |
6 * Do ":help uganda" in Vim to read copying and usage conditions. | |
7 * Do ":help credits" in Vim to see a list of people who contributed. | |
8 */ | |
9 | |
10 | |
11 #ifndef NBDEBUG_H | |
12 #define NBDEBUG_H | |
13 | |
14 #ifdef NBDEBUG | |
15 | |
18753
6e3dc2d630c2
patch 8.1.2366: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
15874
diff
changeset
|
16 # ifndef ASSERT |
6e3dc2d630c2
patch 8.1.2366: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
15874
diff
changeset
|
17 # define ASSERT(c) \ |
7 | 18 if (!(c)) { \ |
19 fprintf(stderr, "Assertion failed: line %d, file %s\n", \ | |
20 __LINE__, __FILE__); \ | |
21 fflush(stderr); \ | |
22 abort(); \ | |
23 } | |
18753
6e3dc2d630c2
patch 8.1.2366: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
15874
diff
changeset
|
24 # endif |
7 | 25 |
18753
6e3dc2d630c2
patch 8.1.2366: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
15874
diff
changeset
|
26 # define nbdebug(a) nbdbg a |
7 | 27 |
18753
6e3dc2d630c2
patch 8.1.2366: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
15874
diff
changeset
|
28 # define NB_TRACE 0x00000001 |
6e3dc2d630c2
patch 8.1.2366: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
15874
diff
changeset
|
29 # define NB_TRACE_VERBOSE 0x00000002 |
6e3dc2d630c2
patch 8.1.2366: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
15874
diff
changeset
|
30 # define NB_TRACE_COLONCMD 0x00000004 |
6e3dc2d630c2
patch 8.1.2366: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
15874
diff
changeset
|
31 # define NB_PRINT 0x00000008 |
6e3dc2d630c2
patch 8.1.2366: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
15874
diff
changeset
|
32 # define NB_DEBUG_ALL 0xffffffff |
7 | 33 |
18753
6e3dc2d630c2
patch 8.1.2366: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
15874
diff
changeset
|
34 # define NBDLEVEL(flags) (nb_debug != NULL && (nb_dlevel & (flags))) |
7 | 35 |
18753
6e3dc2d630c2
patch 8.1.2366: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
15874
diff
changeset
|
36 # define NBDEBUG_TRACE 1 |
7 | 37 |
38 typedef enum { | |
18753
6e3dc2d630c2
patch 8.1.2366: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
15874
diff
changeset
|
39 WT_ENV = 1, // look for env var if set |
6e3dc2d630c2
patch 8.1.2366: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
15874
diff
changeset
|
40 WT_WAIT, // look for ~/.gvimwait if set |
6e3dc2d630c2
patch 8.1.2366: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
15874
diff
changeset
|
41 WT_STOP // look for ~/.gvimstop if set |
7 | 42 } WtWait; |
43 | |
44 | |
15874
c7ba5fed403c
patch 8.1.0944: format of nbdbg() arguments is not checked
Bram Moolenaar <Bram@vim.org>
parents:
10042
diff
changeset
|
45 void nbdbg(char *, ...) |
18753
6e3dc2d630c2
patch 8.1.2366: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
15874
diff
changeset
|
46 # ifdef USE_PRINTF_FORMAT_ATTRIBUTE |
15874
c7ba5fed403c
patch 8.1.0944: format of nbdbg() arguments is not checked
Bram Moolenaar <Bram@vim.org>
parents:
10042
diff
changeset
|
47 __attribute__((format(printf, 1, 2))) |
18753
6e3dc2d630c2
patch 8.1.2366: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
15874
diff
changeset
|
48 # endif |
15874
c7ba5fed403c
patch 8.1.0944: format of nbdbg() arguments is not checked
Bram Moolenaar <Bram@vim.org>
parents:
10042
diff
changeset
|
49 ; |
7 | 50 |
7807
1a5d34492798
commit https://github.com/vim/vim/commit/d99df423c559d85c17779b3685426c489554908c
Christian Brabandt <cb@256bit.org>
parents:
1817
diff
changeset
|
51 void nbdebug_wait(u_int wait_flags, char *wait_var, u_int wait_secs); |
1a5d34492798
commit https://github.com/vim/vim/commit/d99df423c559d85c17779b3685426c489554908c
Christian Brabandt <cb@256bit.org>
parents:
1817
diff
changeset
|
52 void nbdebug_log_init(char *log_var, char *level_var); |
7 | 53 |
54 extern FILE *nb_debug; | |
18753
6e3dc2d630c2
patch 8.1.2366: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
15874
diff
changeset
|
55 extern u_int nb_dlevel; // nb_debug verbosity level |
7 | 56 |
18753
6e3dc2d630c2
patch 8.1.2366: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
15874
diff
changeset
|
57 #else // not NBDEBUG |
7 | 58 |
18753
6e3dc2d630c2
patch 8.1.2366: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
15874
diff
changeset
|
59 # ifndef ASSERT |
6e3dc2d630c2
patch 8.1.2366: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
15874
diff
changeset
|
60 # define ASSERT(c) |
6e3dc2d630c2
patch 8.1.2366: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
15874
diff
changeset
|
61 # endif |
7 | 62 |
63 /* | |
33 | 64 * The following 3 stubs are needed because a macro cannot be used because of |
7 | 65 * the variable number of arguments. |
66 */ | |
67 | |
68 void | |
69 nbdbg( | |
70 char *fmt, | |
71 ...) | |
72 { | |
73 } | |
74 | |
18753
6e3dc2d630c2
patch 8.1.2366: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
15874
diff
changeset
|
75 #endif // NBDEBUG |
6e3dc2d630c2
patch 8.1.2366: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
15874
diff
changeset
|
76 #endif // NBDEBUG_H |