From 328ca1d817898554e30e9b83ce46074a778e45ca Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Mon, 30 Aug 2010 20:13:47 +0000 Subject: [PATCH] src/svf/svf_bison.y: Avoid calling strlen() multiple times on the same string. Fix by Frans Meulenbroeks. git-svn-id: https://urjtag.svn.sourceforge.net/svnroot/urjtag/trunk@1839 b68d4a1b-bc3d-0410-92ed-d4ac073336b7 --- urjtag/ChangeLog | 3 +++ urjtag/src/svf/svf_bison.y | 5 +++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/urjtag/ChangeLog b/urjtag/ChangeLog index ff27134f..cb62e87a 100644 --- a/urjtag/ChangeLog +++ b/urjtag/ChangeLog @@ -14,6 +14,9 @@ * src/svf/svf_flex.l: Use memcpy() rather than strcpy() when we already know the length and we just want to dupe the string. + * src/svf/svf_bison.y: Avoid calling strlen() multiple times on the same + string. Fix by Frans Meulenbroeks. + 2010-08-26 Mike Frysinger * src/tap/cable/gpio.c: Rewrite to use raw file descriptors when working with diff --git a/urjtag/src/svf/svf_bison.y b/urjtag/src/svf/svf_bison.y index a8ce7dc9..979c5836 100644 --- a/urjtag/src/svf/svf_bison.y +++ b/urjtag/src/svf/svf_bison.y @@ -303,7 +303,8 @@ hexa_num_sequence | hexa_num_sequence HEXA_NUM_FRAGMENT { #define REALLOC_STEP (1 << 16) - size_t req_len = $1.strlen + strlen ($2); + size_t frag_len = strlen ($2); + size_t req_len = $1.strlen + frag_len; if ($1.buflen <= req_len) { size_t newlen = req_len - $1.buflen < REALLOC_STEP ? $1.buflen + REALLOC_STEP : req_len + 1; @@ -312,7 +313,7 @@ hexa_num_sequence } if ($1.buf != NULL) { strcat ($1.buf, $2); - $1.strlen += strlen ($2); + $1.strlen += frag_len; } free ($2); $$ = $1;