エラー文字列が空のとき、変数にNULLではなく'\0'を設定するよう変更
[YACASL2.git] / src / casl2.c
index d510e9f..47490a1 100644 (file)
@@ -65,6 +65,7 @@ void assemble(int filec, char *filev[])
 
     create_cmdtype_code();                         /* 命令の名前とタイプがキーのハッシュ表を作成 */
     asptr = malloc_chk(sizeof(ASPTR), "asptr");    /* アセンブル時のプロパティ用の領域確保 */
+    asptr->prog = malloc_chk(sizeof(LABELSIZE + 1), "asptr.prog");
     asptr->ptr = 0;
     /* アセンブル。ラベル表作成のため、2回行う */
     for(pass = FIRST; pass <= SECOND; pass++) {
@@ -96,7 +97,8 @@ void assemble(int filec, char *filev[])
 asfin:
     freelabel();                                  /* ラベルハッシュ表を解放 */
     free_cmdtype_code();                          /* 命令の名前とタイプがキーのハッシュ表を解放 */
-    FREE(asptr);                                  /* アセンブル時のプロパティを解放 */
+    FREE(asptr->prog);                            /* アセンブル時のプロパティを解放 */
+    FREE(asptr);
 }
 
 /**
@@ -167,7 +169,7 @@ int main(int argc, char *argv[])
     }
     /* ソースファイルが指定されていない場合は終了 */
     if(argv[optind] == NULL) {
-        setcerr(126, NULL);    /* no source file */
+        setcerr(126, "");    /* no source file */
         fprintf(stderr, "CASL2 error - %d: %s\n", cerr->num, cerr->msg);
         exit(1);
     }