Corrected what appears to be a long-standing error in the "extract
unique" code. It was using DBEraseLabelsByContent() which would erase all matching labels, and could potentially erase labels that were still remaining on the list being processed, causing a segfault. Also corrected minor errors identified by valgrind during debugging the above-referenced problem.
This commit is contained in:
parent
f7eb54fac7
commit
9931244e1e
|
|
@ -734,8 +734,9 @@ again:
|
|||
}
|
||||
|
||||
/* Remove any ".mag" file extension from the name */
|
||||
if (!strcmp(returnname + strlen(returnname) - 4, ".mag"))
|
||||
*(returnname + strlen(returnname) - 4) = '\0';
|
||||
if (strlen(returnname) > 4)
|
||||
if (!strcmp(returnname + strlen(returnname) - 4, ".mag"))
|
||||
*(returnname + strlen(returnname) - 4) = '\0';
|
||||
|
||||
if (strcmp(returnname, def->cd_name) != 0)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2774,7 +2774,7 @@ DBCellWrite(cellDef, fileName)
|
|||
/* The cd_file should not have the .mag suffix, but make sure */
|
||||
/* it doesn't before adding one. */
|
||||
|
||||
if (strcmp(fileName + strlen(fileName) - 4, DBSuffix))
|
||||
if ((strlen(fileName) < 4) || (strcmp(fileName + strlen(fileName) - 4, DBSuffix)))
|
||||
{
|
||||
realname = (char *) mallocMagic(strlen(fileName) + strlen(DBSuffix) + 1);
|
||||
(void) sprintf(realname, "%s%s", fileName, DBSuffix);
|
||||
|
|
|
|||
|
|
@ -426,9 +426,9 @@ DBEraseLabelsByContent(def, rect, type, text)
|
|||
/*
|
||||
* ----------------------------------------------------------------------------
|
||||
*
|
||||
* DBEraseLabelsByFunction --
|
||||
* DBRemoveLabel --
|
||||
*
|
||||
* Erase any labels found on the label list for which the function returns
|
||||
* Erase a labels by reference.
|
||||
* TRUE.
|
||||
*
|
||||
* Results:
|
||||
|
|
@ -443,19 +443,9 @@ DBEraseLabelsByContent(def, rect, type, text)
|
|||
*/
|
||||
|
||||
void
|
||||
DBEraseLabelsByFunction(def, func)
|
||||
DBRemoveLabel(def, refLab)
|
||||
CellDef *def; /* Where to look for label to delete. */
|
||||
bool (*func)(); /* Function to call for each label. If it
|
||||
* returns TRUE, we delete the label.
|
||||
*
|
||||
* Function should be of the form:
|
||||
*
|
||||
* bool func(lab)
|
||||
* Label *lab;
|
||||
* {
|
||||
* return XXX;
|
||||
* }
|
||||
*/
|
||||
Label *refLab;
|
||||
{
|
||||
Label *lab, *labPrev;
|
||||
|
||||
|
|
@ -464,7 +454,7 @@ DBEraseLabelsByFunction(def, func)
|
|||
labPrev = lab, lab = lab->lab_next)
|
||||
{
|
||||
nextCheck:
|
||||
if (!(*func)(lab)) continue;
|
||||
if (lab != refLab) continue;
|
||||
DBUndoEraseLabel(def, lab);
|
||||
DBWLabelChanged(def, lab, DBW_ALLWINDOWS);
|
||||
if (labPrev == NULL)
|
||||
|
|
|
|||
|
|
@ -729,7 +729,7 @@ extern void DBFontLabelSetBBox();
|
|||
extern bool DBEraseLabel();
|
||||
extern void DBEraseLabelAll();
|
||||
extern void DBEraseLabelsByContent();
|
||||
extern void DBEraseLabelsByFunction();
|
||||
extern void DBRemoveLabel();
|
||||
extern void DBReOrientLabel();
|
||||
extern void DBAdjustLabels();
|
||||
|
||||
|
|
|
|||
|
|
@ -427,9 +427,9 @@ extHardGenerateLabel(scx, reg, arg)
|
|||
len = strlen(gen) + prefixlen;
|
||||
newlab = (Label *) mallocMagic((unsigned) (sizeof (Label) + len - 3));
|
||||
r.r_ll = reg->treg_tile->ti_ll;
|
||||
GEOCLIP(&r,&scx->scx_area);
|
||||
r.r_ur.p_x = r.r_ll.p_x+1;
|
||||
r.r_ur.p_y = r.r_ll.p_y+1;
|
||||
GEOCLIP(&r,&scx->scx_area);
|
||||
GeoTransRect(&scx->scx_trans, &r, &newlab->lab_rect);
|
||||
newlab->lab_type = TiGetType(reg->treg_tile);
|
||||
|
||||
|
|
|
|||
|
|
@ -260,7 +260,7 @@ makeUnique:
|
|||
|
||||
lab = ll2->ll_label;
|
||||
saveLab = *lab;
|
||||
DBEraseLabelsByContent(def, &lab->lab_rect, lab->lab_type, lab->lab_text);
|
||||
DBRemoveLabel(def, lab);
|
||||
(void) DBPutFontLabel(def, &saveLab.lab_rect,
|
||||
saveLab.lab_font, saveLab.lab_size, saveLab.lab_rotate,
|
||||
&saveLab.lab_offset, saveLab.lab_just, name2,
|
||||
|
|
|
|||
Loading…
Reference in New Issue