[Xapian-tickets] [Xapian] #754: Exception in generate_sample with 0 as sample size

Xapian nobody at xapian.org
Tue Jan 16 08:44:53 GMT 2018


#754: Exception in generate_sample with 0 as sample size
---------------------------------+------------------
        Reporter:  samuelharden  |      Owner:  olly
            Type:  defect        |     Status:  new
        Priority:  normal        |  Milestone:
       Component:  Other         |    Version:
        Severity:  normal        |   Keywords:
      Blocked By:                |   Blocking:
Operating System:  All           |
---------------------------------+------------------
 I was trying to input sample size as 0 to generate function and this lead
 to an exception. We should probably handle this case

 Continuing.
 Exception: basic_string::replace: __pos (which is 18446744073709551615) >
 this->size() (which is 2)
 [Inferior 1 (process 3121) exited with code 01]

 Exception occurs at
 https://github.com/xapian/xapian/blob/356ea64fa21c7d6d5974e5e8dac796c000fe84e6
 /xapian-applications/omega/sample.cc#L54 line

                 output.replace(maxlen - ind.size(), string::npos, ind);


 Size of ind is 3 as i sent "..." and maxlen is zero, so it tries to access
 -ve index of string. Which should be prevented.

 Probably better to return an empty string if sample size provided is
 smaller than ind. But i am waiting for feedback from community before
 proposing and writing a patch

--
Ticket URL: <https://trac.xapian.org/ticket/754>
Xapian <https://xapian.org/>
Xapian



More information about the Xapian-tickets mailing list