commit 0ab801c0986b526615a8868ee4a832c10c496d04
parent 3431440dbe7f02932efb51f98477fe9b00ab18ba
Author: conrad <conrad@9c49b5d1-7df3-0310-bce2-b7278e68f44c>
Date: Mon, 21 Apr 2008 19:38:54 +0000
Fix for malloc wrapper, from Yair K. (accidentally dropped from
last patch):
malloc(0) returns NULL on glibc. So if size==0, xs_malloc will exit
with "malloc error". Make sure instead that at least one byte is
allocated. At the moment, This can only happen if INCR returns
*value == 0, which I'm not sure is legal.
git-svn-id: http://svn.kfish.org/xsel/trunk@224 9c49b5d1-7df3-0310-bce2-b7278e68f44c
Diffstat:
1 file changed, 1 insertion(+), 0 deletions(-)
diff --git a/xsel.c b/xsel.c
@@ -265,6 +265,7 @@ xs_malloc (size_t size)
{
void * ret;
+ if (size == 0) size = 1;
if ((ret = malloc (size)) == NULL) {
exit_err ("malloc error");
}