Skip to content

Commit

Permalink
fix: Seg_exist function crashes when the second parameter is 0
Browse files Browse the repository at this point in the history
Co-authored-by: liuchenghao
  • Loading branch information
lk-me authored Aug 9, 2021
1 parent 31617b1 commit 60b8851
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

1 comment on commit 60b8851

@fangfufu
Copy link
Owner

@fangfufu fangfufu commented on 60b8851 Aug 29, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit breaks the cache system, and has been reverted.

Please sign in to comment.