From d46559c55af94ca85a916e2ccc1a402465ad57dd Mon Sep 17 00:00:00 2001 From: miker Date: Mon, 27 Nov 2006 17:27:22 +0000 Subject: [PATCH] off-by-one ... arg git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@803 9efc2488-bf62-4759-914b-345cdb29e865 --- src/utils/utils.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/utils/utils.c b/src/utils/utils.c index ffe738e..3c7a2d6 100644 --- a/src/utils/utils.c +++ b/src/utils/utils.c @@ -254,7 +254,7 @@ int buffer_add_char(growing_buffer* gb, char c) { char* uescape( const char* string, int size, int full_escape ) { growing_buffer* buf = buffer_init(size + 64); - int clen = 1; + int clen = 0; int idx = 0; unsigned long int c = 0x0; @@ -268,19 +268,19 @@ char* uescape( const char* string, int size, int full_escape ) { clen = 1; if (((unsigned char)string[idx] & 0xF0) == 0xF0) { - clen = 4; + clen = 3; c = (unsigned char)string[idx] ^ 0xF0; } else if (((unsigned char)string[idx] & 0xE0) == 0xE0) { - clen = 3; + clen = 2; c = (unsigned char)string[idx] ^ 0xE0; } else if (((unsigned char)string[idx] & 0xC0) == 0xC0) { - clen = 2; + clen = 1; c = (unsigned char)string[idx] ^ 0xC0; } - for (;clen;--clen) { + for (;clen;clen--) { idx++; // look at the next byte c = (c << 6) | ((unsigned char)string[idx] & 0x3F); // add this byte worth -- 2.11.0