Hi, I am wondering if the following is supposed to be safe:
Given a function (from https://searchfox.org/mozilla-central/source/dom/indexedDB/ActorsParent.cpp#9290): nsAutoCString MakeColumnPairSelectionList( const nsLiteralCString& aPlainColumnName, const nsLiteralCString& aLocaleAwareColumnName, const nsLiteralCString& aSortColumnAlias, const bool aIsLocaleAware) { return aPlainColumnName + (aIsLocaleAware ? EmptyCString() : NS_LITERAL_CSTRING(" as ") + aSortColumnAlias) + NS_LITERAL_CSTRING(", ") + aLocaleAwareColumnName + (aIsLocaleAware ? NS_LITERAL_CSTRING(" as ") + aSortColumnAlias : EmptyCString()); } which is used here: const auto& indexTable = mCursor->mUniqueIndex ? NS_LITERAL_CSTRING("unique_index_data") : NS_LITERAL_CSTRING("index_data"); NS_NAMED_LITERAL_CSTRING(sortColumn, "sort_column"); const nsCString sortColumnAlias = NS_LITERAL_CSTRING("SELECT ") + MakeColumnPairSelectionList( NS_LITERAL_CSTRING("index_table.value"), NS_LITERAL_CSTRING("index_table.value_locale"), sortColumn, mCursor->IsLocaleAware()) + NS_LITERAL_CSTRING(", "); nsAutoCString queryStart = sortColumnAlias + NS_LITERAL_CSTRING("xxx") + indexTable + NS_LITERAL_CSTRING("xxx") + kStmtParamNameId; Note that all strings that are concatenated here are either nsLiteralCString or EmptyCString. I stripped down the actual literals in the last statement for readability. While probably not everything else is essential to the problem, but since I am not sure what might be, I left the rest unchanged. On the treeherder builds, this seems to work fine. But reportedly, this crashes on a release build on Mac OS X 10.13 on startup. Static analysis does not catch a problem here. Assigning the result of MakeColumnPairSelectionList to an intermediate variable fixes the issue there (https://phabricator.services.mozilla.com/D49422). I am asking here, since this appears to be a general question on correct use of the string classes. I read through the guide (https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Guide/Internal_strings) but I didn't find anything suspicious. I might have missed some point, though. Thanks a lot Simon _______________________________________________ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform