Thread overview
arsd png bug
Jun 20, 2016
Joerg Joergonson
Jun 20, 2016
Alex Parrill
Jun 20, 2016
Adam D. Ruppe
Jun 21, 2016
Adam D. Ruppe
Jun 21, 2016
Joerg Joergonson
June 20, 2016
1810:
		case 3:
			auto arr = data.dup;
			foreach(i; 0 .. arr.length) {
				auto prev = i < bpp ? 0 : arr[i - bpp];
				if (i >= previousLine.length) break;
				arr[i] += cast(ubyte)
					/*std.math.floor*/( cast(int) (prev + previousLine[i]) / 2);
			}


adding
	if (i >= previousLine.length) break;

prevents some crashes and seems to work.






June 20, 2016
On Monday, 20 June 2016 at 21:39:45 UTC, Joerg Joergonson wrote:
> 1810:
> 		case 3:
> 			auto arr = data.dup;
> 			foreach(i; 0 .. arr.length) {
> 				auto prev = i < bpp ? 0 : arr[i - bpp];
> 				if (i >= previousLine.length) break;
> 				arr[i] += cast(ubyte)
> 					/*std.math.floor*/( cast(int) (prev + previousLine[i]) / 2);
> 			}
>
>
> adding
> 	if (i >= previousLine.length) break;
>
> prevents some crashes and seems to work.

You'd probably get better results by filing an issue with the project's bug tracker [1]. Also by including a sample image that causes the crash.

[1]: https://github.com/adamdruppe/arsd/issues
June 20, 2016
On Monday, 20 June 2016 at 21:53:42 UTC, Alex Parrill wrote:
> You'd probably get better results by filing an issue with the project's bug tracker [1]. Also by including a sample image that causes the crash.

It doesn't make much of a difference to me, it all just ends up in my email inbox anyway.
June 21, 2016
On Monday, 20 June 2016 at 21:39:45 UTC, Joerg Joergonson wrote:
> adding
> 	if (i >= previousLine.length) break;
>
> prevents some crashes and seems to work.

So previousLine should be either the right length or null, so I put in one test.

Can you try it on your test image?

BTW I do a few unnecessary duplications in here too. I think. But there's surely some potential for more memory/performance improvements here.
June 21, 2016
On Tuesday, 21 June 2016 at 00:31:51 UTC, Adam D. Ruppe wrote:
> On Monday, 20 June 2016 at 21:39:45 UTC, Joerg Joergonson wrote:
>> adding
>> 	if (i >= previousLine.length) break;
>>
>> prevents some crashes and seems to work.
>
> So previousLine should be either the right length or null, so I put in one test.
>
> Can you try it on your test image?
>
> BTW I do a few unnecessary duplications in here too. I think. But there's surely some potential for more memory/performance improvements here.

I'll update but can't do any tests since it's random. Seems to be something different with the png encoding. They are auto generated and I've already overwritten the ones that create the bug. (so if it's fixed it will just never occur again, if not it will happen sometime in the future again and I'll let you know).

Every time I've checked it's been previousLine being null and simply putting in that check fixed it, so it is just probably some strange edge case.