Restore cast to avoid overflow.

It's theoretically possible for very large doc IDs (threshold of
INT32_MAX / 8) to overflow the file position.  Cast to int64_t before
performing the multiplication.


Project: http://git-wip-us.apache.org/repos/asf/lucy/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/8bc81c25
Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/8bc81c25
Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/8bc81c25

Branch: refs/heads/master
Commit: 8bc81c25c3521fbd1110a6a5c22c1542767e8de3
Parents: cc9a816
Author: Marvin Humphrey <[email protected]>
Authored: Mon May 2 11:39:49 2016 -0700
Committer: Marvin Humphrey <[email protected]>
Committed: Mon May 2 11:39:49 2016 -0700

----------------------------------------------------------------------
 c/src/Lucy/Index/DocReader.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/8bc81c25/c/src/Lucy/Index/DocReader.c
----------------------------------------------------------------------
diff --git a/c/src/Lucy/Index/DocReader.c b/c/src/Lucy/Index/DocReader.c
index 4677153..3c3445c 100644
--- a/c/src/Lucy/Index/DocReader.c
+++ b/c/src/Lucy/Index/DocReader.c
@@ -44,7 +44,7 @@ DefDocReader_Fetch_Doc_IMP(DefaultDocReader *self, int32_t 
doc_id) {
     char     *field_name = (char*)MALLOCATE(field_name_cap + 1);
 
     // Get data file pointer from index, read number of fields.
-    InStream_Seek(ix_in, doc_id * 8);
+    InStream_Seek(ix_in, (int64_t)doc_id * 8);
     start = InStream_Read_I64(ix_in);
     InStream_Seek(dat_in, start);
     num_fields = InStream_Read_CU32(dat_in);

Reply via email to