Adobe Interview Question
SDE-2sCountry: India
The first time you see h() is returning some value, note it's value, comment out the calling of h() and then use that hardcoded value in g(). This will let you work past the calling of h().
Separately, you can write a test case to debug h() alone to find out the cause of the crash.
If the type of crash is detailed, it could shed a little more light on this problem. But the way i look at it, something within h() messed with the call-stack of g() because essentially the return from a void method is a pop from the call-stack. So i would look at what is the dependency between h() and g(), for instance, are there any pointers being passed, etc.
A possible reason for the issue - Your code crashes at the return statement, it might be the case that your function is overriding the return address in its call stack that happens if you try to provide the local variable with data larger than its buffer size.
- fReaK November 26, 2013