fix: Seg_exist function crashes when the second parameter is 0

Co-authored-by: liuchenghao
This commit is contained in:
MecryWork 2021-08-09 17:36:09 +08:00 committed by GitHub
parent 31617b146c
commit 60b885181a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -983,7 +983,7 @@ long Cache_read(Cache *cf, char * const output_buf, const off_t len,
off_t dl_offset = (offset_start + len) / cf->blksz * cf->blksz;
/* ------------------ Check if the segment already exists ---------------*/
if (Seg_exist(cf, dl_offset)) {
if (dl_offset == 0 || Seg_exist(cf, dl_offset)) {
send = Data_read(cf, (uint8_t *) output_buf, len, offset_start);
goto bgdl;
} else {