From 535453d97d6452edabc729d3c0e7882e30c15e46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Wed, 15 Jun 2011 21:02:31 +0000 Subject: [PATCH] * Reset the passed string on failure for BeOS compatibility. * Fixes #7701. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42200 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/app/Message.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/kits/app/Message.cpp b/src/kits/app/Message.cpp index 1e8c5e46f9..fd3d4bfd3c 100644 --- a/src/kits/app/Message.cpp +++ b/src/kits/app/Message.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2005-2010, Haiku Inc. All rights reserved. + * Copyright 2005-2011, Haiku Inc. All rights reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -2632,12 +2632,15 @@ BMessage::FindString(const char *name, int32 index, BString *string) const if (string == NULL) return B_BAD_VALUE; - const char *cstr; - status_t error = FindString(name, index, &cstr); - if (error < B_OK) + const char *value; + status_t error = FindString(name, index, &value); + if (error != B_OK) { + // Find*() clobbers the object even on failure + string->Truncate(0); return error; + } - *string = cstr; + *string = value; return B_OK; }