mirror of
https://github.com/X11Libre/xf86-video-qxl.git
synced 2026-03-24 01:24:24 +00:00
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>
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user