mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Merge pull request #1720 from binex-dsk/removal/omemo-qrcode-vla
remove VLAs in OMEMO QR Code function
This commit is contained in:
commit
e05e37f7b0
@ -878,17 +878,20 @@ cons_show_qrcode(const char* const text)
|
|||||||
|
|
||||||
ProfWin* console = wins_get_console();
|
ProfWin* console = wins_get_console();
|
||||||
|
|
||||||
char buf[(width * 4) + 1];
|
char* buf = calloc((width * 4) + 1, 1);
|
||||||
memset(buf, 0, sizeof buf);
|
char* pad = calloc((width * 4) + 5, 1);
|
||||||
|
|
||||||
char tmp[(width * 4) + 5];
|
if (!buf || !pad) {
|
||||||
memset(tmp, 0, sizeof tmp);
|
free(pad);
|
||||||
|
free(buf);
|
||||||
for (int i = 0; i < width + 2 * ZOOM_SIZE; i += ZOOM_SIZE) {
|
return;
|
||||||
strcat(tmp, "\u2588\u2588");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
win_println(console, THEME_DEFAULT, "", tmp);
|
for (int i = 0; i < width + 2 * ZOOM_SIZE; i += ZOOM_SIZE) {
|
||||||
|
strcat(pad, "\u2588\u2588");
|
||||||
|
}
|
||||||
|
|
||||||
|
win_println(console, THEME_DEFAULT, "", pad);
|
||||||
for (size_t y = 0; y < width; y += ZOOM_SIZE) {
|
for (size_t y = 0; y < width; y += ZOOM_SIZE) {
|
||||||
for (size_t x = 0; x < width; x += ZOOM_SIZE) {
|
for (size_t x = 0; x < width; x += ZOOM_SIZE) {
|
||||||
strcat(buf, !(*data & 1) ? "\u2588\u2588" : "\u2800\u2800");
|
strcat(buf, !(*data & 1) ? "\u2588\u2588" : "\u2800\u2800");
|
||||||
@ -899,9 +902,12 @@ cons_show_qrcode(const char* const text)
|
|||||||
// The extra squares are for padding, so that the QR code doesn't
|
// The extra squares are for padding, so that the QR code doesn't
|
||||||
// "blend in" with the rest of the terminal window.
|
// "blend in" with the rest of the terminal window.
|
||||||
win_println(console, THEME_DEFAULT, "", "\u2588\u2588%s\u2588\u2588", buf);
|
win_println(console, THEME_DEFAULT, "", "\u2588\u2588%s\u2588\u2588", buf);
|
||||||
memset(buf, 0, sizeof buf);
|
buf[0] = '\0';
|
||||||
}
|
}
|
||||||
win_println(console, THEME_DEFAULT, "", "%s", tmp);
|
win_println(console, THEME_DEFAULT, "", "%s", pad);
|
||||||
|
|
||||||
|
free(pad);
|
||||||
|
free(buf);
|
||||||
|
|
||||||
QRcode_free(qrcode);
|
QRcode_free(qrcode);
|
||||||
#else
|
#else
|
||||||
|
Loading…
Reference in New Issue
Block a user