[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] Avoid malloc in pkl_trans1_ps_string
From: |
Jose E. Marchesi |
Subject: |
Re: [PATCH] Avoid malloc in pkl_trans1_ps_string |
Date: |
Sat, 04 Apr 2020 19:54:50 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) |
Hi Tim!
2020-04-04 Tim Rühsen <address@hidden>
* src/pkl-trans.c (pkl_trans1_ps_string): Avoid malloc if string
does not need escaping.
---
ChangeLog | 5 +++++
src/pkl-trans.c | 5 +++++
2 files changed, 10 insertions(+)
diff --git a/src/pkl-trans.c b/src/pkl-trans.c
index a91d9b3b..5b81a89e 100644
--- a/src/pkl-trans.c
+++ b/src/pkl-trans.c
@@ -269,6 +269,7 @@ PKL_PHASE_BEGIN_HANDLER (pkl_trans1_ps_string)
char *new_string_pointer;
char *p;
size_t string_length, i;
+ bool found_slash = false;
Wouldn't it be more precise to name the variable found_backslash?
/* Please keep this code in sync with the string printer in
pvm-val.c:pvm_print_val. */
@@ -294,11 +295,15 @@ PKL_PHASE_BEGIN_HANDLER (pkl_trans1_ps_string)
PKL_PASS_ERROR;
}
p++;
+ found_slash = true;
}
else
string_length++;
}
+ if (!found_slash)
+ goto _exit;
+
/* Second pass: compose the new string. */
new_string_pointer = xmalloc (string_length + 1);
Other than that, OK for master.
Thanks!