summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHwankyu Jhun <h.jhun@samsung.com>2019-09-09 16:04:07 +0900
committerHwankyu Jhun <h.jhun@samsung.com>2019-09-09 16:04:07 +0900
commit888b581b9831154a65bb3f4e6c82d588d1a78993 (patch)
tree6f35cba423f9f29c9d2702c18612ff37da323424
parentedef76cb8139c7dbf9c1c2582d6ffe703cc7fb69 (diff)
downloadtidl-888b581b9831154a65bb3f4e6c82d588d1a78993.tar.gz
tidl-888b581b9831154a65bb3f4e6c82d588d1a78993.tar.bz2
tidl-888b581b9831154a65bb3f4e6c82d588d1a78993.zip
Fix a segmentation fault
Change-Id: I6e53ac278905ff324e6cb2ab765b417a7c3a6be0 Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
-rw-r--r--idlc/tidlc.yy69
1 files changed, 42 insertions, 27 deletions
diff --git a/idlc/tidlc.yy b/idlc/tidlc.yy
index 3e982a5..b3cc1d6 100644
--- a/idlc/tidlc.yy
+++ b/idlc/tidlc.yy
@@ -148,16 +148,20 @@ structure_block: T_STRUCTURE T_ID T_BRACE_OPEN elements T_BRACE_CLOSE {
;
elements: element {
- $$ = new tidl::Elements();
- $$->Add($1);
+ $$ = new (std::nothrow) tidl::Elements();
+ if ($$ != nullptr) {
+ $$->Add($1);
+ }
}
| elements element {
$$ = $1;
- if ($$->Exist($2)) {
- ps->ReportError("syntax error. \"Already Exists\".", $2->GetLine());
- delete $2;
- } else {
- $$->Add($2);
+ if ($2 != nullptr) {
+ if ($$->Exist($2)) {
+ ps->ReportError("syntax error. \"Already Exists\".", $2->GetLine());
+ delete $2;
+ } else {
+ $$->Add($2);
+ }
}
}
| elements error T_SEMICOLON {
@@ -186,16 +190,20 @@ element: base_type T_ID T_SEMICOLON {
;
attributes: attribute {
- $$ = new tidl::Attributes();
- $$->Add($1);
+ $$ = new (std::nothrow) tidl::Attributes();
+ if ($$ != nullptr) {
+ $$->Add($1);
+ }
}
| attributes T_COMMA attribute {
$$ = $1;
- if ($$->Exist($3)) {
- ps->ReportError("syntax error. \"Already Exist\".", $3->GetLine());
- delete $3;
- } else {
- $$->Add($3);
+ if ($3 != nullptr) {
+ if ($$->Exist($3)) {
+ ps->ReportError("syntax error. \"Already Exist\".", $3->GetLine());
+ delete $3;
+ } else {
+ $$->Add($3);
+ }
}
}
| error {
@@ -254,16 +262,20 @@ interface_block: T_INTERFACE T_ID T_BRACE_OPEN declarations T_BRACE_CLOSE {
;
declarations: declaration {
- $$ = new tidl::Declarations();
- $$->Add($1);
+ $$ = new (std::nothrow) tidl::Declarations();
+ if ($$ != nullptr) {
+ $$->Add($1);
+ }
}
| declarations declaration {
$$ = $1;
- if ($$->Exist($2)) {
- ps->ReportError("syntax error. \"Already Exists\".", $2->GetLine());
- delete $2;
- } else {
- $$->Add($2);
+ if ($2 != nullptr) {
+ if ($$->Exist($2)) {
+ ps->ReportError("syntax error. \"Already Exists\".", $2->GetLine());
+ delete $2;
+ } else {
+ $$->Add($2);
+ }
}
}
| declarations error T_SEMICOLON {
@@ -331,16 +343,19 @@ declaration: base_type T_ID T_LEFT parameter_list T_RIGHT T_SEMICOLON {
parameter_list: parameter {
$$ = new tidl::Parameters();
- if ($1 != nullptr)
+ if ($1 != nullptr) {
$$->Add($1);
+ }
}
| parameter_list T_COMMA parameter {
$$ = $1;
- if ($$->Exist($3)) {
- ps->ReportError("syntax error. \"Already Exists\".", $3->GetLine());
- delete $3;
- } else {
- $$->Add($3);
+ if ($3 != nullptr) {
+ if ($$->Exist($3)) {
+ ps->ReportError("syntax error. \"Already Exists\".", $3->GetLine());
+ delete $3;
+ } else {
+ $$->Add($3);
+ }
}
}
| error {