From: brian m. carlson Date: Sun, 25 Feb 2018 20:28:16 GMT Subject: Re: [PATCH v2 5/5] Revert "repository: pre-initialize hash algo pointer" Message-ID: <20180225202816.GE4620@genre.crustytoothpaste.net> In-Reply-To: On Sun, Feb 25, 2018 at 10:29:29AM +0700, Duy Nguyen wrote: > When I set unknown hash algo here, I think some test failed > mysteriously because it used rawsz field (which has value zero), it > didn't match some expectation, the code went to the error handling > path, which eventually failed with some error message, but it's not > obvious that the problem was rawsz being zero and back tracking that > took me some time. > > With NULL hash_algo, any dereferencing fails immediately with a nice > stack trace. Another reason to push me towards NULL hash algo is, even > if we prefer nice messages over segmentation faults, we can't avoid it > completely anyway (empty_tree and empty_blob are still NULL in unknown > hash algo and will cause segfaults). Might as well make things > consistent and always segfault. That makes sense. Thanks for the explanation. -- brian m. carlson / brian with sandals: Houston, Texas, US https://www.crustytoothpaste.net/~bmc | My opinion only OpenPGP: https://keybase.io/bk2204