~mdw
/
sgt
/
putty
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add a missing null pointer check in one of the dialog box functions.
[sgt/putty]
/
windows
/
winstore.c
diff --git
a/windows/winstore.c
b/windows/winstore.c
index
12d6cdd
..
66c7c75
100644
(file)
--- a/
windows/winstore.c
+++ b/
windows/winstore.c
@@
-186,68
+186,64
@@
int read_setting_i(void *handle, const char *key, int defvalue)
return val;
}
return val;
}
-
int read_setting_fontspec(void *handle, const char *name, FontSpec *result
)
+
FontSpec *read_setting_fontspec(void *handle, const char *name
)
{
char *settingname;
{
char *settingname;
- FontSpec ret;
char *fontname;
char *fontname;
+ int isbold, height, charset;
fontname = read_setting_s(handle, name);
if (!fontname)
fontname = read_setting_s(handle, name);
if (!fontname)
- return 0;
- strncpy(ret.name, fontname, sizeof(ret.name)-1);
- ret.name[sizeof(ret.name)-1] = '\0';
- sfree(fontname);
+ return NULL;
settingname = dupcat(name, "IsBold", NULL);
settingname = dupcat(name, "IsBold", NULL);
-
ret.
isbold = read_setting_i(handle, settingname, -1);
+ isbold = read_setting_i(handle, settingname, -1);
sfree(settingname);
sfree(settingname);
- if (
ret.isbold == -1) return 0
;
+ if (
isbold == -1) return NULL
;
settingname = dupcat(name, "CharSet", NULL);
settingname = dupcat(name, "CharSet", NULL);
-
ret.
charset = read_setting_i(handle, settingname, -1);
+ charset = read_setting_i(handle, settingname, -1);
sfree(settingname);
sfree(settingname);
- if (
ret.charset == -1) return 0
;
+ if (
charset == -1) return NULL
;
settingname = dupcat(name, "Height", NULL);
settingname = dupcat(name, "Height", NULL);
-
ret.
height = read_setting_i(handle, settingname, INT_MIN);
+ height = read_setting_i(handle, settingname, INT_MIN);
sfree(settingname);
sfree(settingname);
- if (
ret.height == INT_MIN) return 0
;
- *result = ret;
- return
1
;
+ if (
height == INT_MIN) return NULL
;
+
+ return
fontspec_new(fontname, isbold, height, charset)
;
}
}
-void write_setting_fontspec(void *handle, const char *name, FontSpec font)
+void write_setting_fontspec(void *handle, const char *name, FontSpec
*
font)
{
char *settingname;
{
char *settingname;
- write_setting_s(handle, name, font
.
name);
+ write_setting_s(handle, name, font
->
name);
settingname = dupcat(name, "IsBold", NULL);
settingname = dupcat(name, "IsBold", NULL);
- write_setting_i(handle, settingname, font
.
isbold);
+ write_setting_i(handle, settingname, font
->
isbold);
sfree(settingname);
settingname = dupcat(name, "CharSet", NULL);
sfree(settingname);
settingname = dupcat(name, "CharSet", NULL);
- write_setting_i(handle, settingname, font
.
charset);
+ write_setting_i(handle, settingname, font
->
charset);
sfree(settingname);
settingname = dupcat(name, "Height", NULL);
sfree(settingname);
settingname = dupcat(name, "Height", NULL);
- write_setting_i(handle, settingname, font
.
height);
+ write_setting_i(handle, settingname, font
->
height);
sfree(settingname);
}
sfree(settingname);
}
-
int read_setting_filename(void *handle, const char *name, Filename *result
)
+
Filename *read_setting_filename(void *handle, const char *name
)
{
char *tmp = read_setting_s(handle, name);
if (tmp) {
{
char *tmp = read_setting_s(handle, name);
if (tmp) {
- strncpy(result->path, tmp, sizeof(result->path)-1);
- result->path[sizeof(result->path)-1] = '\0';
+ Filename *ret = filename_from_str(tmp);
sfree(tmp);
sfree(tmp);
- return
TRUE
;
+ return
ret
;
} else
} else
- return
FALSE
;
+ return
NULL
;
}
}
-void write_setting_filename(void *handle, const char *name, Filename result)
+void write_setting_filename(void *handle, const char *name, Filename
*
result)
{
{
- write_setting_s(handle, name, result
.
path);
+ write_setting_s(handle, name, result
->
path);
}
void close_settings_r(void *handle)
}
void close_settings_r(void *handle)
@@
-460,7
+456,10
@@
enum { DEL, OPEN_R, OPEN_W };
static int try_random_seed(char const *path, int action, HANDLE *ret)
{
if (action == DEL) {
static int try_random_seed(char const *path, int action, HANDLE *ret)
{
if (action == DEL) {
- remove(path);
+ if (!DeleteFile(path) && GetLastError() != ERROR_FILE_NOT_FOUND) {
+ nonfatal("Unable to delete '%s': %s", path,
+ win_strerror(GetLastError()));
+ }
*ret = INVALID_HANDLE_VALUE;
return FALSE; /* so we'll do the next ones too */
}
*ret = INVALID_HANDLE_VALUE;
return FALSE; /* so we'll do the next ones too */
}