Fixed up some bugs that clang's static analysis reported.
authorRyan C. Gordon <icculus@icculus.org>
Tue, 18 Oct 2011 15:55:29 -0400
changeset 1191 f02c977477b9
parent 1188 17bcf6924240
child 1192 586f4cdee6af
Fixed up some bugs that clang's static analysis reported.
src/archiver_qpak.c
src/archiver_unpacked.c
src/physfs.c
--- a/src/archiver_qpak.c	Thu Oct 06 03:24:53 2011 -0400
+++ b/src/archiver_qpak.c	Tue Oct 18 15:55:29 2011 -0400
@@ -525,19 +525,22 @@
     const QPAKinfo *info = (const QPAKinfo *) opaque;
     const QPAKentry *entry = qpak_find_entry(info, filename, &isDir);
 
-    *exists = ((isDir) || (entry != NULL));
-    if (!exists)
-        return 0;
-
     if (isDir)
     {
+        *exists = 1;
         stat->filetype = PHYSFS_FILETYPE_DIRECTORY;
         stat->filesize = 0;
     } /* if */
+    else if (entry != NULL)
+    {
+        *exists = 1;
+        stat->filetype = PHYSFS_FILETYPE_REGULAR;
+        stat->filesize = entry->size;
+    } /* else if */
     else
     {
-        stat->filetype = PHYSFS_FILETYPE_REGULAR;
-        stat->filesize = entry->size;
+        *exists = 0;
+        return 0;
     } /* else */
 
     stat->modtime = -1;
--- a/src/archiver_unpacked.c	Thu Oct 06 03:24:53 2011 -0400
+++ b/src/archiver_unpacked.c	Tue Oct 18 15:55:29 2011 -0400
@@ -216,7 +216,7 @@
 {
     PHYSFS_Io *retval = NULL;
     UNPKinfo *info = (UNPKinfo *) opaque;
-    UNPKfileinfo *finfo;
+    UNPKfileinfo *finfo = NULL;
     UNPKentry *entry;
 
     entry = findEntry(info, fnm);
--- a/src/physfs.c	Thu Oct 06 03:24:53 2011 -0400
+++ b/src/physfs.c	Tue Oct 18 15:55:29 2011 -0400
@@ -394,11 +394,10 @@
         void (*destruct)(void *) = info->destruct;
         void *buf = (void *) info->buf;
         io->opaque = NULL;  /* kill this here in case of race. */
-        destruct = info->destruct;
         allocator.Free(info);
         allocator.Free(io);
         if (destruct != NULL)
-        destruct(buf);
+            destruct(buf);
     } /* if */
 } /* memoryIo_destroy */
 
@@ -2388,11 +2387,10 @@
         buffer = ((PHYSFS_uint8 *) buffer) + buffered;
         len -= buffered;
         retval = buffered;
-        buffered = fh->buffill = fh->bufpos = 0;
+        fh->buffill = fh->bufpos = 0;
     } /* if */
 
     /* if you got here, the buffer is drained and we still need bytes. */
-    assert(buffered == 0);
     assert(len > 0);
 
     io = fh->io;