]> git.draconx.ca Git - liblbx.git/blobdiff - src/image.c
liblbx: Properly report errors in lbx_(img_)fopen.
[liblbx.git] / src / image.c
index f407a2d72d594157f4d05b353364c5720baa8f9d..4657208a05ae28439496346473c8de7cb1566023 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * 2ooM: The Master of Orion II Reverse Engineering Project
  * Library for working with LBX image files.
- * Copyright © 2006-2011 Nick Bowler
+ * Copyright © 2006-2011, 2013 Nick Bowler
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -176,14 +176,17 @@ struct lbx_image *lbx_img_fopen(const char *file)
        FILE *f;
 
        f = fopen(file, "rb");
-       if (!f)
+       if (!f) {
+               lbx_error_raise(-errno);
                return NULL;
+       }
 
        if (fseek(f, 0, SEEK_CUR) == 0)
                return lbx_img_open(f, &lbx_default_fops, file_close);
 
        p = malloc(sizeof *p);
        if (!p) {
+               lbx_error_raise(LBX_ENOMEM);
                fclose(f);
                return NULL;
        }