asprintf returns -1 if memory allocation fails and that's what we're really protecting here. So check for -1 instead of > 0 result.
In general, when asprintf returns 0, then the memory allocation succeeded, but no bytes printed. If we only free the allocated memory when the result is > 0, then we miss the 0 condition and leak. asprintf docs don't say much about whether a 0 result can occur when the string passed in is clearly not empty... but better safe than sorry. Signed-off-by: U. Artie Eoff <ullysses.a.e...@intel.com> --- clients/terminal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clients/terminal.c b/clients/terminal.c index cc603e9..a2253c1 100644 --- a/clients/terminal.c +++ b/clients/terminal.c @@ -838,7 +838,7 @@ update_title(struct terminal *terminal) { if (window_is_resizing(terminal->window)) { char *p; - if (asprintf(&p, "%s — [%dx%d]", terminal->title, terminal->width, terminal->height) > 0) { + if (asprintf(&p, "%s — [%dx%d]", terminal->title, terminal->width, terminal->height) != -1) { window_set_title(terminal->window, p); free(p); } -- 1.9.0 _______________________________________________ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel