]> granicus.if.org Git - yasm/commitdiff
gas-bison.y: Fix crash when .ident is used with an object format that
authorPeter Johnson <peter@tortall.net>
Mon, 20 Nov 2006 01:20:11 +0000 (01:20 -0000)
committerPeter Johnson <peter@tortall.net>
Mon, 20 Nov 2006 01:20:11 +0000 (01:20 -0000)
doesn't support the .comment section.

svn path=/trunk/yasm/; revision=1691

modules/parsers/gas/gas-bison.y

index 5eb62bd22c31841a52bec31454f5594a5638b9d8..0a4d01ccc453ba955cdb09957082a3e2acceca7f 100644 (file)
@@ -449,20 +449,25 @@ lineexp: instr
        /*@dependent@*/ yasm_section *comment =
            gas_get_section(parser_gas, yasm__xstrdup(".comment"), NULL, NULL,
                            NULL, 1);
-       /* To match GAS output, if the comment section is empty, put an
-        * initial 0 byte in the section.
-        */
-       if (yasm_section_bcs_first(comment) == yasm_section_bcs_last(comment)) {
-           yasm_datavalhead dvs;
-
-           yasm_dvs_initialize(&dvs);
-           yasm_dvs_append(&dvs, yasm_dv_create_expr(
-               p_expr_new_ident(yasm_expr_int(yasm_intnum_create_uint(0)))));
+       if (comment) {
+           /* To match GAS output, if the comment section is empty, put an
+            * initial 0 byte in the section.
+            */
+           if (yasm_section_bcs_first(comment)
+               == yasm_section_bcs_last(comment)) {
+               yasm_datavalhead dvs;
+
+               yasm_dvs_initialize(&dvs);
+               yasm_dvs_append(&dvs, yasm_dv_create_expr(
+                   p_expr_new_ident(yasm_expr_int(
+                       yasm_intnum_create_uint(0)))));
+               yasm_section_bcs_append(comment,
+                   yasm_bc_create_data(&dvs, 1, 0, parser_gas->arch,
+                                       cur_line));
+           }
            yasm_section_bcs_append(comment,
-               yasm_bc_create_data(&dvs, 1, 0, parser_gas->arch, cur_line));
+               yasm_bc_create_data(&$2, 1, 1, parser_gas->arch, cur_line));
        }
-       yasm_section_bcs_append(comment,
-           yasm_bc_create_data(&$2, 1, 1, parser_gas->arch, cur_line));
        $$ = NULL;
     }
     | DIR_FILE INTNUM STRING {