Skip to content

Commit 23e6aa4

Browse files
committed
hf/lf tune: fix segfault when called from script
1 parent b758181 commit 23e6aa4

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ All notable changes to this project will be documented in this file.
33
This project uses the changelog in accordance with [keepchangelog](http://keepachangelog.com/). Please use this to write notable changes, which is not the same as git commit log...
44

55
## [unreleased][unreleased]
6-
- Add option to set and get maximum read/write block number using `hf_mf_ultimatecard` script (@piotrva)
6+
- Fixed `hf/lf tune` segfault when called from script (@doegox)
7+
- Added option to set and get maximum read/write block number using `hf_mf_ultimatecard` script (@piotrva)
78
- Added JEDEC information for SPI flash W25Q64JV (@ANTodorov)
89
- Added special iclass legacy config cards in `hf iclass configcard` (@antiklesys)
910
- Added simulation function to `hf iclass legrec` (@antiklesys)

client/src/ui.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -696,14 +696,18 @@ void print_progress(uint64_t count, uint64_t max, barMode_t style) {
696696
max = (count > max) ? count : max;
697697
#if defined(HAVE_READLINE)
698698
static int prev_cols = 0;
699-
int rows;
700-
rl_reset_screen_size(); // refresh Readline idea of the actual screen width
701-
rl_get_screen_size(&rows, &cols);
702-
703-
if (cols < 36)
704-
return;
699+
int tmp_cols;
700+
rl_get_screen_size(NULL, &tmp_cols);
701+
// if cols==0: impossible to get screen size, e.g. when scripted
702+
if (tmp_cols != 0) {
703+
// don't call it if cols==0, it would segfault
704+
rl_reset_screen_size(); // refresh Readline idea of the actual screen width
705+
rl_get_screen_size(NULL, &cols);
706+
707+
if (cols < 36)
708+
return;
709+
}
705710

706-
(void) rows;
707711
if (prev_cols > cols) {
708712
PrintAndLogEx(NORMAL, _CLEAR_ _TOP_ "");
709713
}

0 commit comments

Comments
 (0)