summaryrefslogtreecommitdiff
path: root/pinentry-dmenu.c
diff options
context:
space:
mode:
authorMoritz Luedecke <ritze@skweez.net>2017-09-10 11:18:02 +0200
committerMoritz Luedecke <ritze@skweez.net>2017-09-10 11:18:02 +0200
commit9241e51a8153494bc1f689e04608a1335d515c96 (patch)
treeeb79a7d7810b52597e1d9016588c24e30be680c4 /pinentry-dmenu.c
parent72044dca8af1195997353f86c067c4eae58c94bd (diff)
Only allocate memory if needed
Diffstat (limited to 'pinentry-dmenu.c')
-rw-r--r--pinentry-dmenu.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/pinentry-dmenu.c b/pinentry-dmenu.c
index a39bb73..9004a3e 100644
--- a/pinentry-dmenu.c
+++ b/pinentry-dmenu.c
@@ -152,7 +152,7 @@ drawwin(void) {
size_t asterlen = strlen(asterisk);
size_t pdesclen;
int leftinput;
- char* censort = ecalloc(1, asterlen * pinentry->pin_len);
+ char* censort;
unsigned int censortl = minpwlen * TEXTW(asterisk) / strlen(asterisk);
unsigned int confirml = TEXTW(" YesNo ") + 3 * lrpad;
@@ -204,6 +204,8 @@ drawwin(void) {
drw_setscheme(drw, scheme[SchemeNormal]);
if (winmode == WinPin) {
+ censort = ecalloc(1, asterlen * pinentry->pin_len);
+
for (i = 0; i < asterlen * strlen(pin); i += asterlen) {
memcpy(&censort[i], asterisk, asterlen);
}
@@ -217,13 +219,14 @@ drawwin(void) {
drw_setscheme(drw, scheme[SchemeNormal]);
drw_rect(drw, x + curpos, 2, 2, bh - 4, 1, 0);
}
+
+ free(censort);
} else {
x += TEXTW(" ");
x = drawitem("No", (sel == No), x, 0, TEXTW("No"));
x = drawitem("Yes", (sel == Yes), x, 0, TEXTW("Yes"));
}
- free(censort);
drw_map(drw, win, 0, 0, mw, mh);
}