]> git.draconx.ca Git - liblbx.git/blobdiff - src/lbx.c
liblbx: Improve error handling in lbx_file_seek.
[liblbx.git] / src / lbx.c
index 30cd156c957e747392046f5c9f9b7637f0580fdc..1198ebbc2c0b13e08aa4cbb7c914ae431d4eb48c 100644 (file)
--- a/src/lbx.c
+++ b/src/lbx.c
@@ -282,10 +282,15 @@ int lbx_file_seek(struct lbx_file_state *f, long offset, int whence)
        case SEEK_END:
                pos = f->limit + offset;
                break;
+       default:
+               lbx_error_raise(LBX_EINVAL);
+               return -1;
        }
 
-       if (pos > f->limit)
+       if (pos > f->limit) {
+               lbx_error_raise(LBX_EINVAL);
                return -1;
+       }
 
        f->lbx->last_file = NULL;
        if (fops->seek(f->lbx->f, f->base + pos, SEEK_SET) != 0)