summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristophe Fergeau <cfergeau@redhat.com>2016-12-15 10:47:51 +0100
committerChristophe Fergeau <cfergeau@redhat.com>2016-12-19 17:28:19 +0100
commit009776a8a3fb096b11ec95033d1e1a366e26f188 (patch)
tree8a7f5acd73464db5498f7fbeff48cee464c68d1e
parentdb353f559d32119e811eab71a9d3128847a64609 (diff)
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 <cfergeau@redhat.com> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
-rw-r--r--src/spiceqxl_audio.c2
-rw-r--r--src/spiceqxl_main_loop.c4
-rw-r--r--src/spiceqxl_spice_server.c12
3 files changed, 9 insertions, 9 deletions
diff --git a/src/spiceqxl_audio.c b/src/spiceqxl_audio.c
index 52a45f0..ec9260d 100644
--- a/src/spiceqxl_audio.c
+++ b/src/spiceqxl_audio.c
@@ -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);
diff --git a/src/spiceqxl_main_loop.c b/src/spiceqxl_main_loop.c
index af20a5a..0213693 100644
--- a/src/spiceqxl_main_loop.c
+++ b/src/spiceqxl_main_loop.c
@@ -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);
diff --git a/src/spiceqxl_spice_server.c b/src/spiceqxl_spice_server.c
index 6e8cf50..38257d0 100644
--- a/src/spiceqxl_spice_server.c
+++ b/src/spiceqxl_spice_server.c
@@ -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);
}
}