Skip to content

Commit 527f145

Browse files
committed
SDL: Validate window dimensions on loading to prevent hidden window
1 parent b0f61de commit 527f145

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

ChangeLog

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
2021-07-28 (12.23)
1+
2021-08-22 (12.23)
2+
SDL: Validate window dimensions on loading to prevent hidden window
3+
4+
2021-08-16 (12.23)
25
COMMON: Fix array append regression #122
36
UI: added window hideKeypad #125
47

5-
2021-07-28 (12.23)
8+
2021-08-16 (12.23)
69
ANDROID: Hide keypad on run. Show keypad for INPUT, then re-hide on completion.
710

811
2021-07-28 (12.22)

src/platform/sdl/settings.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -87,14 +87,14 @@ FILE *openConfig(bool readMode, Settings settings) {
8787
//
8888
// returns the next integer from the file
8989
//
90-
int nextInteger(FILE *fp, int def) {
90+
int nextInteger(FILE *fp, int min, int def) {
9191
int result = 0;
9292
for (int c = fgetc(fp); c != EOF && c != ',' && c != '\n'; c = fgetc(fp)) {
9393
if (c != '\r') {
9494
result = (result * 10) + (c - '0');
9595
}
9696
}
97-
if (!result) {
97+
if (result < min) {
9898
result = def;
9999
}
100100
return result;
@@ -160,14 +160,14 @@ void restorePath(FILE *fp, bool restoreDir) {
160160
void restoreSettings(SDL_Rect &rect, int &fontScale, bool debug, bool restoreDir) {
161161
FILE *fp = openConfig(true, debug ? k_debug : k_window);
162162
if (fp) {
163-
rect.x = nextInteger(fp, SDL_WINDOWPOS_UNDEFINED);
164-
rect.y = nextInteger(fp, SDL_WINDOWPOS_UNDEFINED);
165-
rect.w = nextInteger(fp, DEFAULT_WIDTH);
166-
rect.h = nextInteger(fp, DEFAULT_HEIGHT);
167-
fontScale = nextInteger(fp, DEFAULT_SCALE);
168-
opt_mute_audio = nextInteger(fp, 0);
169-
opt_ide = nextInteger(fp, 0) ? IDE_INTERNAL : IDE_NONE;
170-
g_themeId = nextInteger(fp, 0);
163+
rect.x = nextInteger(fp, 0, SDL_WINDOWPOS_UNDEFINED);
164+
rect.y = nextInteger(fp, 0, SDL_WINDOWPOS_UNDEFINED);
165+
rect.w = nextInteger(fp, 100, DEFAULT_WIDTH);
166+
rect.h = nextInteger(fp, 100, DEFAULT_HEIGHT);
167+
fontScale = nextInteger(fp, 30, DEFAULT_SCALE);
168+
opt_mute_audio = nextInteger(fp, 0, 0);
169+
opt_ide = nextInteger(fp, 0, 0) ? IDE_INTERNAL : IDE_NONE;
170+
g_themeId = nextInteger(fp, 0, 0);
171171
for (int i = 0; i < THEME_COLOURS; i++) {
172172
g_user_theme[i] = nextHex(fp, g_user_theme[i]);
173173
}

0 commit comments

Comments
 (0)