From 389b362cceb2f46a85b4dd629d9e8de0a063c730 Mon Sep 17 00:00:00 2001 From: Shirou WAKAYAMA Date: Thu, 22 Jan 2015 15:16:09 +0900 Subject: [PATCH] if not NULL terminated, size is not set correctly. --- common/common.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/common/common.go b/common/common.go index a3fa3eb..fc0c6dd 100644 --- a/common/common.go +++ b/common/common.go @@ -54,15 +54,17 @@ func ReadLinesOffsetN(filename string, offset uint, n int) ([]string, error) { func IntToString(orig []int8) string { ret := make([]byte, len(orig)) - size := 0 + size := -1 for i, o := range orig { if o == 0 { size = i break } - ret[i] = byte(o) } + if size == -1 { + size = len(orig) + } return string(ret[0:size]) }