Hello!
For last few hours I've been hunting a bug in one of my C apps.
After calling malloc (same happened with calloc) one of variables suddenly changed value.
I've tested this many, many times. I still can't believe it [besides it's 2:10am here)
Could someone look this under the scope?
I've trimmed down source, so it's very small
I've also wrote small sh script to test this without debugger. Right now it's not all that much of a help, because I commented out part of code, that was reading stdin, and then manipulated, that data.
But still it sets environment, so you can simply ./run.sh to see what really happens.
It's really weird things going on with that source.
stderr output on my pc (32bit)
Bought were supposed to be equal (4)
Huge thanks in advance.
EDIT:
btw, static analysis didn't return any errors as well
For last few hours I've been hunting a bug in one of my C apps.
After calling malloc (same happened with calloc) one of variables suddenly changed value.
I've tested this many, many times. I still can't believe it [besides it's 2:10am here)
Could someone look this under the scope?
I've trimmed down source, so it's very small
I've also wrote small sh script to test this without debugger. Right now it's not all that much of a help, because I commented out part of code, that was reading stdin, and then manipulated, that data.
But still it sets environment, so you can simply ./run.sh to see what really happens.
It's really weird things going on with that source.
stderr output on my pc (32bit)
Code:
DEBUG1: 4
DEBUG2: 675295296
Huge thanks in advance.
EDIT:
btw, static analysis didn't return any errors as well