Skip to content

Enry changes the input byte slice #196

@vmarkovtsev

Description

@vmarkovtsev

enry.GetLanguage changes the contents of its second argument - the byte slice. How to reproduce:

reproduce.go

package main

import (
    "io/ioutil"
    "os"

    "gopkg.in/src-d/enry.v1"
)

func main() {
    data, _ := ioutil.ReadAll(os.Stdin)
    language := enry.GetLanguage("ParabolicPointer.cs", data)
    os.Stdout.Write(data)
    println(language)
}
cat ParabolicPointer.cs | go run reproduce.go > new.cs
diff ParabolicPointer.cs new.cs

You should see

50c50
<         for(int i=0; i<points; i++)
---
>         for(int i=0; i<points;>i++)

ParabolicPointer.cs: ParabolicPointer.zip

This is the root cause of src-d/hercules#178

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions