X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;ds=sidebyside;f=sha1_file.c;h=ac7bf9fd271cd538e733d31332ab29cf36e4a69f;hb=0746b620010d5e3b48f6fdb210edf3a066d0bc6a;hp=e6fdaa217a8ef7d2ac58e705d72bb7b34fd49282;hpb=6b0c3121061df6b323f430700e8077b324b5e9dd;p=git.git diff --git a/sha1_file.c b/sha1_file.c index e6fdaa21..ac7bf9fd 100644 --- a/sha1_file.c +++ b/sha1_file.c @@ -329,7 +329,7 @@ void * unpack_sha1_file(void *map, unsigned long mapsize, char *type, unsigned l return NULL; bytes = strlen(buffer) + 1; - buf = xmalloc(*size); + buf = xmalloc(1+*size); memcpy(buf, buffer + bytes, stream.total_out - bytes); bytes = stream.total_out - bytes; @@ -339,6 +339,7 @@ void * unpack_sha1_file(void *map, unsigned long mapsize, char *type, unsigned l while (inflate(&stream, Z_FINISH) == Z_OK) /* nothing */; } + buf[*size] = 0; inflateEnd(&stream); return buf; }