DynASM: Fix crash in dasm_encode() when some section is empty

Fixes GH #1041
This commit is contained in:
Dmitry Stogov 2023-08-03 10:37:25 +03:00
parent 8635cbabf3
commit e795b8a7ae
5 changed files with 5 additions and 0 deletions

View File

@ -141,6 +141,7 @@ void dasm_setup(Dst_DECL, const void *actionlist)
memset((void *)D->lglabels, 0, D->lgsize); memset((void *)D->lglabels, 0, D->lgsize);
if (D->pclabels) memset((void *)D->pclabels, 0, D->pcsize); if (D->pclabels) memset((void *)D->pclabels, 0, D->pcsize);
for (i = 0; i < D->maxsection; i++) { for (i = 0; i < D->maxsection; i++) {
D->sections[i].rbuf = D->sections[i].buf - DASM_SEC2POS(i);
D->sections[i].pos = DASM_SEC2POS(i); D->sections[i].pos = DASM_SEC2POS(i);
D->sections[i].ofs = 0; D->sections[i].ofs = 0;
} }

View File

@ -143,6 +143,7 @@ void dasm_setup(Dst_DECL, const void *actionlist)
memset((void *)D->lglabels, 0, D->lgsize); memset((void *)D->lglabels, 0, D->lgsize);
if (D->pclabels) memset((void *)D->pclabels, 0, D->pcsize); if (D->pclabels) memset((void *)D->pclabels, 0, D->pcsize);
for (i = 0; i < D->maxsection; i++) { for (i = 0; i < D->maxsection; i++) {
D->sections[i].rbuf = D->sections[i].buf - DASM_SEC2POS(i);
D->sections[i].pos = DASM_SEC2POS(i); D->sections[i].pos = DASM_SEC2POS(i);
D->sections[i].ofs = 0; D->sections[i].ofs = 0;
} }

View File

@ -140,6 +140,7 @@ void dasm_setup(Dst_DECL, const void *actionlist)
memset((void *)D->lglabels, 0, D->lgsize); memset((void *)D->lglabels, 0, D->lgsize);
if (D->pclabels) memset((void *)D->pclabels, 0, D->pcsize); if (D->pclabels) memset((void *)D->pclabels, 0, D->pcsize);
for (i = 0; i < D->maxsection; i++) { for (i = 0; i < D->maxsection; i++) {
D->sections[i].rbuf = D->sections[i].buf - DASM_SEC2POS(i);
D->sections[i].pos = DASM_SEC2POS(i); D->sections[i].pos = DASM_SEC2POS(i);
D->sections[i].ofs = 0; D->sections[i].ofs = 0;
} }

View File

@ -140,6 +140,7 @@ void dasm_setup(Dst_DECL, const void *actionlist)
memset((void *)D->lglabels, 0, D->lgsize); memset((void *)D->lglabels, 0, D->lgsize);
if (D->pclabels) memset((void *)D->pclabels, 0, D->pcsize); if (D->pclabels) memset((void *)D->pclabels, 0, D->pcsize);
for (i = 0; i < D->maxsection; i++) { for (i = 0; i < D->maxsection; i++) {
D->sections[i].rbuf = D->sections[i].buf - DASM_SEC2POS(i);
D->sections[i].pos = DASM_SEC2POS(i); D->sections[i].pos = DASM_SEC2POS(i);
D->sections[i].ofs = 0; D->sections[i].ofs = 0;
} }

View File

@ -139,6 +139,7 @@ void dasm_setup(Dst_DECL, const void *actionlist)
memset((void *)D->lglabels, 0, D->lgsize); memset((void *)D->lglabels, 0, D->lgsize);
if (D->pclabels) memset((void *)D->pclabels, 0, D->pcsize); if (D->pclabels) memset((void *)D->pclabels, 0, D->pcsize);
for (i = 0; i < D->maxsection; i++) { for (i = 0; i < D->maxsection; i++) {
D->sections[i].rbuf = D->sections[i].buf - DASM_SEC2POS(i);
D->sections[i].pos = DASM_SEC2POS(i); D->sections[i].pos = DASM_SEC2POS(i);
D->sections[i].ofs = 0; D->sections[i].ofs = 0;
} }