~mdw
/
sgt
/
putty
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Missing assert.
[sgt/putty]
/
windows
/
winctrls.c
diff --git
a/windows/winctrls.c
b/windows/winctrls.c
index
4afd3d0
..
72d462e
100644
(file)
--- a/
windows/winctrls.c
+++ b/
windows/winctrls.c
@@
-448,6
+448,8
@@
char *staticwrap(struct ctlpos *cp, HWND hwnd, char *text, int *lines)
if (lines) *lines = nlines;
if (lines) *lines = nlines;
+ sfree(pwidths);
+
return ret;
}
return ret;
}
@@
-1291,6
+1293,7
@@
void winctrl_remove(struct winctrls *wc, struct winctrl *c)
{
struct winctrl *ret;
ret = del234(wc->byctrl, c);
{
struct winctrl *ret;
ret = del234(wc->byctrl, c);
+ assert(ret == c);
ret = del234(wc->byid, c);
assert(ret == c);
}
ret = del234(wc->byid, c);
assert(ret == c);
}
@@
-1665,7
+1668,9
@@
void winctrl_layout(struct dlgparam *dp, struct winctrls *wc,
winctrl_add_shortcuts(dp, c);
if (actual_base_id == base_id)
base_id += num_ids;
winctrl_add_shortcuts(dp, c);
if (actual_base_id == base_id)
base_id += num_ids;
- }
+ } else {
+ sfree(data);
+ }
if (colstart >= 0) {
/*
if (colstart >= 0) {
/*
@@
-2102,19
+2107,8
@@
char *dlg_editbox_get(union control *ctrl, void *dlg)
{
struct dlgparam *dp = (struct dlgparam *)dlg;
struct winctrl *c = dlg_findbyctrl(dp, ctrl);
{
struct dlgparam *dp = (struct dlgparam *)dlg;
struct winctrl *c = dlg_findbyctrl(dp, ctrl);
- char *ret;
- int size;
assert(c && c->ctrl->generic.type == CTRL_EDITBOX);
assert(c && c->ctrl->generic.type == CTRL_EDITBOX);
-
- size = 0;
- ret = NULL;
- do {
- size = size * 4 / 3 + 512;
- ret = sresize(ret, size, char);
- GetDlgItemText(dp->hwnd, c->base_id+1, ret, size);
- } while (!memchr(ret, '\0', size-1));
-
- return ret;
+ return GetDlgItemText_alloc(dp->hwnd, c->base_id+1);
}
/* The `listbox' functions can also apply to combo boxes. */
}
/* The `listbox' functions can also apply to combo boxes. */
@@
-2294,21
+2288,25
@@
void dlg_label_change(union control *ctrl, void *dlg, char const *text)
}
}
}
}
-void dlg_filesel_set(union control *ctrl, void *dlg, Filename fn)
+void dlg_filesel_set(union control *ctrl, void *dlg, Filename
*
fn)
{
struct dlgparam *dp = (struct dlgparam *)dlg;
struct winctrl *c = dlg_findbyctrl(dp, ctrl);
assert(c && c->ctrl->generic.type == CTRL_FILESELECT);
{
struct dlgparam *dp = (struct dlgparam *)dlg;
struct winctrl *c = dlg_findbyctrl(dp, ctrl);
assert(c && c->ctrl->generic.type == CTRL_FILESELECT);
- SetDlgItemText(dp->hwnd, c->base_id+1, fn
.
path);
+ SetDlgItemText(dp->hwnd, c->base_id+1, fn
->
path);
}
}
-
void dlg_filesel_get(union control *ctrl, void *dlg, Filename *fn
)
+
Filename *dlg_filesel_get(union control *ctrl, void *dlg
)
{
struct dlgparam *dp = (struct dlgparam *)dlg;
struct winctrl *c = dlg_findbyctrl(dp, ctrl);
{
struct dlgparam *dp = (struct dlgparam *)dlg;
struct winctrl *c = dlg_findbyctrl(dp, ctrl);
+ char *tmp;
+ Filename *ret;
assert(c && c->ctrl->generic.type == CTRL_FILESELECT);
assert(c && c->ctrl->generic.type == CTRL_FILESELECT);
- GetDlgItemText(dp->hwnd, c->base_id+1, fn->path, lenof(fn->path));
- fn->path[lenof(fn->path)-1] = '\0';
+ tmp = GetDlgItemText_alloc(dp->hwnd, c->base_id+1);
+ ret = filename_from_str(tmp);
+ sfree(tmp);
+ return ret;
}
void dlg_fontsel_set(union control *ctrl, void *dlg, FontSpec *fs)
}
void dlg_fontsel_set(union control *ctrl, void *dlg, FontSpec *fs)
@@
-2373,6
+2371,8
@@
void dlg_set_focus(union control *ctrl, void *dlg)
struct winctrl *c = dlg_findbyctrl(dp, ctrl);
int id;
HWND ctl;
struct winctrl *c = dlg_findbyctrl(dp, ctrl);
int id;
HWND ctl;
+ if (!c)
+ return;
switch (ctrl->generic.type) {
case CTRL_EDITBOX: id = c->base_id + 1; break;
case CTRL_RADIO:
switch (ctrl->generic.type) {
case CTRL_EDITBOX: id = c->base_id + 1; break;
case CTRL_RADIO: