Skip to content

Commit ae7b318

Browse files
committed
viewer#875 Crash at uri normalization
Note that crash happened when setting LLProgressView::setMessage
1 parent ae6aa3f commit ae7b318

File tree

3 files changed

+28
-14
lines changed

3 files changed

+28
-14
lines changed

indra/llcommon/lluriparser.cpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,10 @@ void LLUriParser::extractParts()
164164
#if LL_DARWIN
165165
typedef void(*sighandler_t)(int);
166166
jmp_buf return_to_normalize;
167+
static int sLastSignal = 0;
167168
void uri_signal_handler(int signal)
168169
{
170+
sLastSignal = signal;
169171
// Apparently signal handler throwing an exception doesn't work.
170172
// This is ugly and unsafe due to not unwinding content of uriparser library,
171173
// but unless we have a way to catch this as NSexception, jump appears to be the only option.
@@ -179,8 +181,10 @@ S32 LLUriParser::normalize()
179181
if (!mRes)
180182
{
181183
#if LL_DARWIN
182-
sighandler_t last_handler;
183-
last_handler = signal(SIGILL, &uri_signal_handler); // illegal instruction
184+
sighandler_t last_sigill_handler, last_sigbus_handler;
185+
last_sigill_handler = signal(SIGILL, &uri_signal_handler); // illegal instruction
186+
last_sigbus_handler = signal(SIGBUS, &uri_signal_handler);
187+
184188
if (setjmp(return_to_normalize))
185189
{
186190
// Issue: external library crashed via signal
@@ -194,16 +198,18 @@ S32 LLUriParser::normalize()
194198
// if this can be handled by NSexception, it needs to be remade
195199
llassert(0);
196200

197-
LL_WARNS() << "Uriparser crashed with SIGILL, while processing: " << mNormalizedUri << LL_ENDL;
198-
signal(SIGILL, last_handler);
201+
LL_WARNS() << "Uriparser crashed with " << sLastSignal << " , while processing: " << mNormalizedUri << LL_ENDL;
202+
signal(SIGILL, last_sigill_handler);
203+
signal(SIGBUS, last_sigbus_handler);
199204
return 1;
200205
}
201206
#endif
202207

203208
mRes = uriNormalizeSyntaxExA(&mUri, URI_NORMALIZE_SCHEME | URI_NORMALIZE_HOST);
204209

205210
#if LL_DARWIN
206-
signal(SIGILL, last_handler);
211+
signal(SIGILL, last_sigill_handler);
212+
signal(SIGBUS, last_sigbus_handler);
207213
#endif
208214

209215
if (!mRes)
@@ -226,7 +232,7 @@ S32 LLUriParser::normalize()
226232
}
227233
}
228234

229-
if(mTmpScheme)
235+
if(mTmpScheme && mNormalizedUri.size() > 7)
230236
{
231237
mNormalizedUri = mNormalizedUri.substr(7);
232238
mTmpScheme = false;

indra/llui/llurlentry.cpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -234,14 +234,20 @@ bool LLUrlEntryBase::isWikiLinkCorrect(const std::string &labeled_url) const
234234

235235
std::string LLUrlEntryBase::urlToLabelWithGreyQuery(const std::string &url) const
236236
{
237+
if (url.empty())
238+
{
239+
return url;
240+
}
237241
LLUriParser up(escapeUrl(url));
238-
up.normalize();
239-
240-
std::string label;
241-
up.extractParts();
242-
up.glueFirst(label);
242+
if (up.normalize() == 0)
243+
{
244+
std::string label;
245+
up.extractParts();
246+
up.glueFirst(label);
243247

244-
return unescapeUrl(label);
248+
return unescapeUrl(label);
249+
}
250+
return std::string();
245251
}
246252

247253
std::string LLUrlEntryBase::urlToGreyQuery(const std::string &url) const

indra/llui/llurlregistry.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,8 +221,10 @@ bool LLUrlRegistry::findUrl(const std::string &text, LLUrlMatch &match, const LL
221221
if (match_entry == mUrlEntryTrusted)
222222
{
223223
LLUriParser up(url);
224-
up.normalize();
225-
url = up.normalizedUri();
224+
if (up.normalize() == 0)
225+
{
226+
url = up.normalizedUri();
227+
}
226228
}
227229

228230
match.setValues(match_start, match_end,

0 commit comments

Comments
 (0)