Summary: | code import crash | ||
---|---|---|---|
Product: | [Applications] umbrello | Reporter: | justin_wu <justin.wu.z> |
Component: | general | Assignee: | Umbrello Development Group <umbrello-devel> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | code, gabravier, okellogg, zhongjie007 |
Priority: | NOR | ||
Version: | unspecified | ||
Target Milestone: | --- | ||
Platform: | Arch Linux | ||
OS: | Linux | ||
Latest Commit: | https://invent.kde.org/sdk/umbrello/commit/ef7e41fe2c99045a5fe6301c5aed92267a410d9c | Version Fixed In: | 2.36.80 (KDE releases 22.11.80) |
Sentry Crash Report: |
Description
justin_wu
2022-07-07 02:27:53 UTC
I have a patch to fix this. you should patch `lib/cppparser/parser.cpp` with below.
>> I think use `&(*std::unique_ptr)` is superfluous. `std::unique_ptr.get()` have the same effect. Hope the maintainer fix this as soon as possible
***
umbrello branch release/22.08
***
```
diff --color -uprN a/lib/cppparser/parser.cpp b/lib/cppparser/parser.cpp
--- a/lib/cppparser/parser.cpp 2022-10-11 03:38:32.000000000 +0800
+++ b/lib/cppparser/parser.cpp 2022-10-25 00:45:11.678067641 +0800
@@ -1844,7 +1844,7 @@ template<class Type>
void Parser::eventuallyTakeComment(int startLn, int endLn, Type& ast)
{
if (comment().line() >= startLn && comment().line() <= endLn) {
- if (&(*ast)) {
+ if (ast.get()) {
if (comment()) {
ast->setComment(comment());
}
@@ -1860,7 +1860,7 @@ void Parser::eventuallyTakeComment(Type&
int line = currentLine();
Comment c = m_commentStore.getCommentsInRange(line, true);
- if (&(*ast) && c) {
+ if (ast.get() && c) {
ast->setComment(c);
}
}
@@ -3158,7 +3158,7 @@ bool Parser::parseDeclarationInternal(De
int endSignature = m_lexer->index();
Comment mcomment;
- if (&(*declarator)) {
+ if (declarator.get()) {
int endLine, endColumn;
declarator->getEndPosition(&endLine, &endColumn);
mcomment = m_commentStore.getCommentsInRange(endLine);
@@ -3294,7 +3294,7 @@ start_decl:
}
Comment mcomment;
- if (&(*decl)) {
+ if (decl.get()) {
int line, col;
decl->getEndPosition(&line, &col);
mcomment = m_commentStore.getCommentsInRange(line);
@@ -3311,7 +3311,7 @@ start_decl:
SimpleDeclarationAST::Node ast = CreateNode<SimpleDeclarationAST>();
int line, col;
ast->setComment(mcomment);
- if (&(*decl)) {
+ if (decl.get()) {
decl->getEndPosition(&line, &col);
preparseLineComments(line);
@@ -3343,7 +3343,7 @@ start_decl:
FunctionDefinitionAST::Node ast = CreateNode<FunctionDefinitionAST>();
ast->setComment(mcomment);
- if (&(*decl)) {
+ if (decl.get()) {
int line, col;
decl->getEndPosition(&line, &col);
```
I think the problem is that these classes depend on some KDE stuff which define AST as a macro which formerly was probably std::auto_ptr, but in more recent versions uses std::unique_ptr. If the unique_ptr is wrapping a NULL pointer, then of course the &(*) etc. will crash hbecause this is dereferencing a NULL pointer. However, `operator bool()` is overloaded in `std::unique_ptr`, so one could also write simply: ``` if (declarator) { // etc. ``` instead of: ``` if (&(*declarator)) { ``` or ``` if (declarator.get())) { ``` As you said, source code change std::auto_prt to std::unique_ptr serveral release ago, but forgot to fix `&(*declarator)`. Your advice is very useful. Git commit 035c942f83e0d8d39b31c531f237e8ccc0895656 by Oliver Kellogg. Committed on 19/11/2022 at 19:35. Pushed by okellogg into branch 'release/22.12'. lib/cppparser/parser.cpp : Apply patch of comment #1 by Xuxu. Thanks. FIXED-IN: 2.36.80 (KDE releases 22.11.80) M +6 -6 lib/cppparser/parser.cpp https://invent.kde.org/sdk/umbrello/commit/035c942f83e0d8d39b31c531f237e8ccc0895656 (In reply to justin_wu from comment #0) > [...] > STEPS TO REPRODUCE > 1. download live555 source code, > http://www.live555.com/liveMedia/public/live.2022.06.16.tar.gz That version is no longer available but I downloaded live.2022.10.01.tar.gz and with this version and Xuxu's patch applied, that problem did not happen. Git commit ef7e41fe2c99045a5fe6301c5aed92267a410d9c by Oliver Kellogg. Committed on 27/11/2022 at 20:32. Pushed by okellogg into branch 'master'. lib/cppparser/parser.cpp : Apply patch of comment #1 by Xuxu. Thanks. FIXED-IN: 2.36.80 (KDE releases 22.11.80) M +6 -6 lib/cppparser/parser.cpp https://invent.kde.org/sdk/umbrello/commit/ef7e41fe2c99045a5fe6301c5aed92267a410d9c *** Bug 461738 has been marked as a duplicate of this bug. *** |