libgit2/libgit2 — Issue #592: Bad Ptr from readdir
Author: sc68cal
Created: 2012-03-07 22:10:49+00:00
State: open

I am trying to track down the cause behind libgit2/libgit2sharp#123

There appears to be a bad return from [readdir in path.c](https://github.com/libgit2/libgit2/blob/development/src/path.c#L505)

Local variables
```
path	0x0013f1b0 {ptr=0x0328ddb8 "E:/git/Case Refresh - CS Exam Updates/" asize=64 size=38 }	git_buf *
fn	0x10029a20 alphasorted_dirent_cb(void *, git_buf *)	int (void *, git_buf *)*
arg	0x0013f134	void *
dir	0x03220068 {h=0xfeeefeee f={...} entry={...} ...}	git__DIR *
wd_len	38	long
de	0x00000000 {d_ino=??? d_name=0x00000004 }	git__dirent *
```

Call stack
```
git2.dll!git_path_direach(git_buf * path, int (void *, git_buf *)* fn, void * arg) Line 523	C
git2.dll!alphasorted_futils_direach(git_buf * path, int (void *, git_buf *)* fn, void * arg) Line 753 + 0x12 bytes	C
git2.dll!git_status_foreach(git_repository * repo, int (const char *, unsigned int, void *)* callback, void * payload) Line 522 + 0x12 bytes	C
[External Code]
LibGit2Sharp.dll!LibGit2Sharp.RepositoryStatus.RepositoryStatus(LibGit2Sharp.Repository repo) Line 40 + 0x38 bytes	C#
LibGit2Sharp.dll!LibGit2Sharp.Index.RetrieveStatus() Line 512 + 0x1b bytes	C#
libgit2debug.exe!libgit2debug.Program.Main(string[] args) Line 15 + 0x17 bytes	C#
```