Fixed fake OOM bug in transfergetdata.
authorFredrik Tolf <fredrik@dolda2000.com>
Thu, 29 Nov 2007 20:14:46 +0000 (21:14 +0100)
committerFredrik Tolf <fredrik@dolda2000.com>
Thu, 29 Nov 2007 20:14:46 +0000 (21:14 +0100)
daemon/transfer.c

index bebe011..e2fe54e 100644 (file)
@@ -292,8 +292,12 @@ void *transfergetdata(struct transfer *transfer, size_t *size)
        return(NULL);
     if((transfer->endpos >= 0) && (transfer->curpos + *size >= transfer->endpos))
     {
-       *size = transfer->endpos - transfer->curpos;
-       buf = srealloc(buf, *size);
+       if((*size = transfer->endpos - transfer->curpos) == 0) {
+           free(buf);
+           buf = NULL;
+       } else {
+           buf = srealloc(buf, *size);
+       }
     }
     transfer->curpos += *size;
     bytesupload += *size;