Skip to content

Commit

Permalink
[tx_shared] Properly re-alloc memory for selected FD and free the pre…
Browse files Browse the repository at this point in the history
…vious memory. More work needed for this in the future.
  • Loading branch information
kaydeearts committed Mar 31, 2023
1 parent a4eae8a commit ef164a5
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion c/shared/source/tx_shared/tx_shared.c
Original file line number Diff line number Diff line change
Expand Up @@ -2558,8 +2558,20 @@ static void t1_EndFont(txCtx h) {

/* Convert to name-keyed font */
h->top->sup.flags &= ~ABF_CID_FONT;
abfFontDict* selectedFD = &h->top->FDArray.array[h->t1w.fd];

abfFontDict* temp = memNew(h, sizeof(abfFontDict));
memcpy(temp, selectedFD, sizeof(abfFontDict));
temp->FontName.ptr = memNew(h, strlen(selectedFD->FontName.ptr) + 1);
strcpy(temp->FontName.ptr, selectedFD->FontName.ptr);
for (int i=0; i< h->top->FDArray.cnt; i++) {
char* fdFontName = h->top->FDArray.array[i].FontName.ptr;
if (fdFontName != NULL)
xmlFree(fdFontName);
}
memFree(h, h->top->FDArray.array);
h->top->FDArray.cnt = 1;
h->top->FDArray.array = &h->top->FDArray.array[h->t1w.fd];
h->top->FDArray.array = temp;
h->t1w.options |= T1W_NO_UID; /* Clear UniqueIDs */
}

Expand Down

0 comments on commit ef164a5

Please sign in to comment.