summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--buffer.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/buffer.c b/buffer.c
index 0ca50b4..a462374 100644
--- a/buffer.c
+++ b/buffer.c
@@ -209,6 +209,7 @@ char* buf_getstring(buffer* buf, unsigned int *retlen) {
unsigned int len;
char* ret;
+ void* src = NULL;
len = buf_getint(buf);
if (len > MAX_STRING_LEN) {
dropbear_exit("String too long");
@@ -217,8 +218,9 @@ char* buf_getstring(buffer* buf, unsigned int *retlen) {
if (retlen != NULL) {
*retlen = len;
}
+ src = buf_getptr(buf, len);
ret = m_malloc(len+1);
- memcpy(ret, buf_getptr(buf, len), len);
+ memcpy(ret, src, len);
buf_incrpos(buf, len);
ret[len] = '\0';