git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] Fix deletion of last character in levenshtein distance

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Nov 19, 2008, 00:53 UTC
Message-ID
<alpine.DEB.1.00.0811190151000.30769@pacific.mpi-cbg.de>
In-Reply-To
<20081118185326.12721.71576.stgit@arrakis.enst.fr>
Hi,
On Tue, 18 Nov 2008, Samuel Tardieu wrote:
Show 10 quoted lines
> diff --git a/levenshtein.c b/levenshtein.c
> index db52f2c..98fea72 100644
> --- a/levenshtein.c
> +++ b/levenshtein.c
> @@ -25,7 +25,7 @@ int levenshtein(const char *string1, const char *string2,
>  					row2[j + 1] > row0[j - 1] + w)
>  				row2[j + 1] = row0[j - 1] + w;
>  			/* deletion */
> -			if (j + 1 < len2 && row2[j + 1] > row1[j + 1] + d)
> +			if (row2[j + 1] > row1[j + 1] + d)

I do not understand: does row2 have more entries than len2? In any case, you will _have_ to guard against accessing elements outside the reserved memory.

You'll have to be more convincing to make me agree that this is a good change, and I am pretty certain that other people are less familiar with that particular part of Git's source code than me.

Ciao, Dscho

Previous: Matthieu MoyNext: Samuel Tardieu
Message 3 of 12 in “Fix deletion of last character in levenshtein distance”
  1. Fix deletion of last character in levenshtein distanceSamuel Tardieu, Nov 18, 2008
  2. Matthieu MoyNov 18, 2008
  3. Johannes SchindelinNov 19, 2008
  4. Samuel TardieuNov 19, 2008
  5. Johannes SchindelinNov 19, 2008
  6. Junio C HamanoNov 19, 2008
  7. Document levenshtein.cJohannes Schindelin, Nov 20, 2008
  8. Samuel TardieuNov 20, 2008
  9. Document levenshtein.cJohannes Schindelin, Nov 20, 2008
  10. Jon LoeligerNov 20, 2008
  11. Sverre RabbelierNov 20, 2008
  12. Johannes SchindelinNov 20, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.