Skip to content

Commit

Permalink
d.barscale: Fix Resource Leak issue in draw_scale.c (#4959)
Browse files Browse the repository at this point in the history
  • Loading branch information
ShubhamDesai authored Jan 17, 2025
1 parent f5e278f commit fc9418d
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion display/d.barscale/draw_scale.c
Original file line number Diff line number Diff line change
Expand Up @@ -634,8 +634,12 @@ int draw_scale(double east, double north, int length, int seg, int units,
}
D_stroke();

if (fontsize < 0)
if (fontsize < 0) {
if (length != 0) {
G_free(label);
}
return 0;
}

/* draw the distance + units text */

Expand Down Expand Up @@ -676,6 +680,9 @@ int draw_scale(double east, double north, int length, int seg, int units,
D_pos_abs(x_pos + 5 - (tr - tl), y_pos + ysize / 2 + (tt - tb) / 2);
D_text(label);
}
if (length != 0) {
G_free(label);
}

return 0;
}

0 comments on commit fc9418d

Please sign in to comment.