diff options
-rw-r--r-- | buffer.c | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -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'; |