From ca16e6264f8d901e97051c2cb4a14e12e1fce211 Mon Sep 17 00:00:00 2001 From: jvoisin Date: Mon, 15 Jan 2018 17:22:30 +0100 Subject: Fix an other off-by-one --- src/sp_utils.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/sp_utils.c b/src/sp_utils.c index 81941f7..6612e6c 100644 --- a/src/sp_utils.c +++ b/src/sp_utils.c @@ -284,11 +284,9 @@ bool sp_match_array_key(const zval* zv, const char* to_match, const pcre* rx) { return true; } } else { - char* idx_str = NULL; + char* idx_str = emalloc(snprintf(NULL, 0, "%lu", idx) + 1); - // Could use a log. - idx_str = emalloc(snprintf(NULL, 0, "%lu", idx)); - sprintf(idx_str, "%lu", idx); + sprintf(idx_str, "%lu", idx); // This could use a log. if (sp_match_value(idx_str, to_match, rx)) { efree(idx_str); return true; -- cgit v1.3