[haiku-commits] Re: haiku: hrev47314 - src/kits/network/libnetapi

  • From: Stephan Aßmus <superstippi@xxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Thu, 05 Jun 2014 10:27:39 +0200

Am 05.06.2014 09:30, schrieb Axel Dörfler:
On June 5, 2014 at 12:00 AM superstippi@xxxxxx wrote:
+     char* resultChar = result.LockBuffer(MD5_DIGEST_LENGTH * 2);
        for (int i = 0; i < MD5_DIGEST_LENGTH; i++) {
                char c = ((hashResult[i] & 0xF0) >> 4);
                c += (c > 9) ? 'a' - 10 : '0';
-             result << c;
+             resultChar[0] = c;

How about checking whether LockBuffer() succeeded?

I did think about that. You mean since I added that code and it should be 100% correct? The problem is that all the code in there does not do any error checking for allocation failures. It doesn't help if it's done at one place deep into the call stack. I think it sucks that we don't use exceptions for handling errors such as these. The code is full of string manipulation, and BString reallocates for almost every added or removed byte. One would have to check for failure almost after every manipulation. What would you suggest?

Best regards,
-Stephan



Other related posts: