On Thu, Oct 1, 2015 at 8:15 PM, Harmandeep Kaur <write.harmand...@gmail.com> wrote: > @@ -1881,7 +1881,7 @@ static struct iovec *lock_iovec(int type, abi_ulong > target_addr, > return NULL; > } > > - vec = calloc(count, sizeof(struct iovec)); > + vec = g_try_new0(struct iovec, count); > if (vec == NULL) { > errno = ENOMEM; > return NULL; > @@ -1945,7 +1945,7 @@ static struct iovec *lock_iovec(int type, abi_ulong > target_addr, > } > unlock_user(target_vec, target_addr, 0); > fail2: > - free(vec); > + g_free(vec); > errno = err; > return NULL; > }
unlock_iovec() must use g_free(). > @@ -2672,14 +2672,14 @@ static inline abi_long target_to_host_semarray(int > semid, unsigned short **host_ > > nsems = semid_ds.sem_nsems; > > - *host_array = malloc(nsems*sizeof(unsigned short)); > + *host_array = g_try_new(unsigned short, nsems); > if (!*host_array) { > return -TARGET_ENOMEM; > } > array = lock_user(VERIFY_READ, target_addr, > nsems*sizeof(unsigned short), 1); > if (!array) { > - free(*host_array); > + g_free(*host_array); > return -TARGET_EFAULT; > } > host_to_target_semarray() must use g_free().