Commit 009776a8 authored by Christophe Fergeau's avatar Christophe Fergeau

Xspice: Replace malloc/strdup use with xnfalloc/xnfstrdup

spiceqxl_*.c files are Xspice-only code. They contain a few uses of
malloc/strdup, and none of these are checked for failure. It's better to
replace these with xfnalloc/xnfstrdup which are provided by the X server
and cannot fail (aborts on failure).
Signed-off-by: Christophe Fergeau's avatarChristophe Fergeau <cfergeau@redhat.com>
Reviewed-by: 's avatarHans de Goede <hdegoede@redhat.com>
parent db353f55
......@@ -405,7 +405,7 @@ static void handle_one_change(qxl_screen_t *qxl, struct inotify_event *e)
return;
}
fname = malloc(strlen(e->name) + strlen(qxl->playback_fifo_dir) + 1 + 1);
fname = xnfalloc(strlen(e->name) + strlen(qxl->playback_fifo_dir) + 1 + 1);
strcpy(fname, qxl->playback_fifo_dir);
strcat(fname, "/");
strcat(fname, e->name);
......
......@@ -209,7 +209,7 @@ int watch_count = 0;
static SpiceWatch *watch_add(int fd, int event_mask, SpiceWatchFunc func, void *opaque)
{
SpiceWatch *watch = malloc(sizeof(SpiceWatch));
SpiceWatch *watch = xnfalloc(sizeof(SpiceWatch));
DPRINTF(0, "adding %p, fd=%d at %d", watch,
fd, watch_count);
......@@ -381,7 +381,7 @@ static int watch_update_mask_internal(SpiceWatch *watch, int event_mask)
static SpiceWatch *watch_add(int fd, int event_mask, SpiceWatchFunc func, void *opaque)
{
SpiceWatch *watch = malloc(sizeof(SpiceWatch));
SpiceWatch *watch = xnfalloc(sizeof(SpiceWatch));
DPRINTF(0, "adding %p, fd=%d", watch, fd);
......
......@@ -200,23 +200,23 @@ void xspice_set_spice_server_options(OptionInfoPtr options)
len = strlen(x509_dir) + 32;
if (x509_key_file_base) {
x509_key_file = strdup(x509_key_file_base);
x509_key_file = xnfstrdup(x509_key_file_base);
} else {
x509_key_file = malloc(len);
x509_key_file = xnfalloc(len);
snprintf(x509_key_file, len, "%s/%s", x509_dir, X509_SERVER_KEY_FILE);
}
if (x509_cert_file_base) {
x509_cert_file = strdup(x509_cert_file_base);
x509_cert_file = xnfstrdup(x509_cert_file_base);
} else {
x509_cert_file = malloc(len);
x509_cert_file = xnfalloc(len);
snprintf(x509_cert_file, len, "%s/%s", x509_dir, X509_SERVER_CERT_FILE);
}
if (x509_cacert_file_base) {
x509_cacert_file = strdup(x509_cert_file_base);
x509_cacert_file = xnfstrdup(x509_cert_file_base);
} else {
x509_cacert_file = malloc(len);
x509_cacert_file = xnfalloc(len);
snprintf(x509_cacert_file, len, "%s/%s", x509_dir, X509_CA_CERT_FILE);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment