From: Ross Lagerwall Date: Sun, 20 Jul 2014 07:13:45 +0000 (+0100) Subject: libnfs.c: Handle OOM condition X-Git-Tag: upstream/1.9.6^2~17^2~1 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=ece11036ff6894f7c7d447e7a3d64c0cd49d9aa2;p=deb_libnfs.git libnfs.c: Handle OOM condition Signed-off-by: Ross Lagerwall --- diff --git a/lib/libnfs.c b/lib/libnfs.c index 2f2dc4f..a134a2c 100644 --- a/lib/libnfs.c +++ b/lib/libnfs.c @@ -2630,6 +2630,13 @@ static void nfs_create_2_cb(struct rpc_context *rpc, int status, void *command_d /* copy the filehandle */ nfsfh->fh.data.data_len = res->LOOKUP3res_u.resok.object.data.data_len; nfsfh->fh.data.data_val = malloc(nfsfh->fh.data.data_len); + if (nfsfh->fh.data.data_val == NULL) { + rpc_set_error(nfs->rpc, "Out of memory: Failed to allocate fh structure"); + data->cb(-ENOMEM, nfs, rpc_get_error(nfs->rpc), data->private_data); + free_nfs_cb_data(data); + free(nfsfh); + return -1; + } memcpy(nfsfh->fh.data.data_val, res->LOOKUP3res_u.resok.object.data.data_val, nfsfh->fh.data.data_len); /* Try to truncate it if we were requested to */