summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2010-07-24 16:57:39 +0200
committerBram Moolenaar <Bram@vim.org>2010-07-24 16:57:39 +0200
commit904c622b105bf785df59f870831309d5c0c7722e (patch)
treee4e48fc718a1f1b255ec436db40bd76a42201c0d /src
parent5dff57d7140b95b46b16926a0f4bc5c39d359df4 (diff)
Fix: errors for allocating zero bytes when profiling an empty function.
Diffstat (limited to 'src')
-rw-r--r--src/eval.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/eval.c b/src/eval.c
index a819373460..33be998e0d 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -21176,18 +21176,21 @@ builtin_function(name)
func_do_profile(fp)
ufunc_T *fp;
{
+ int len = fp->uf_lines.ga_len;
+
+ if (len == 0)
+ len = 1; /* avoid getting error for allocating zero bytes */
fp->uf_tm_count = 0;
profile_zero(&fp->uf_tm_self);
profile_zero(&fp->uf_tm_total);
if (fp->uf_tml_count == NULL)
- fp->uf_tml_count = (int *)alloc_clear((unsigned)
- (sizeof(int) * fp->uf_lines.ga_len));
+ fp->uf_tml_count = (int *)alloc_clear((unsigned) (sizeof(int) * len));
if (fp->uf_tml_total == NULL)
fp->uf_tml_total = (proftime_T *)alloc_clear((unsigned)
- (sizeof(proftime_T) * fp->uf_lines.ga_len));
+ (sizeof(proftime_T) * len));
if (fp->uf_tml_self == NULL)
fp->uf_tml_self = (proftime_T *)alloc_clear((unsigned)
- (sizeof(proftime_T) * fp->uf_lines.ga_len));
+ (sizeof(proftime_T) * len));
fp->uf_tml_idx = -1;
if (fp->uf_tml_count == NULL || fp->uf_tml_total == NULL
|| fp->uf_tml_self == NULL)