diff options
| author | Clement Sibille <clements+git@lisible.xyz> | 2024-03-06 12:32:55 +0900 | 
|---|---|---|
| committer | Clement Sibille <clements+git@lisible.xyz> | 2024-03-06 12:32:55 +0900 | 
| commit | 90c87f38c6c6b8cff5fc310708fa9805b1cfa426 (patch) | |
| tree | 65ab1bb6097b2ebb4bfb2bbdae444bab65ff24f2 | |
| parent | 1769d0007b79ce5a054a22d39409dab22f2889b2 (diff) | |
Improve error handling in lisiblepng-bin
| -rw-r--r-- | lisiblepng-bin/src/main.c | 11 | 
1 files changed, 7 insertions, 4 deletions
diff --git a/lisiblepng-bin/src/main.c b/lisiblepng-bin/src/main.c index 7e99bfe..6b52f2f 100644 --- a/lisiblepng-bin/src/main.c +++ b/lisiblepng-bin/src/main.c @@ -17,20 +17,23 @@ int main(int argc, char **argv) {    if (!png_file) {      const char *error_message = strerror(errno);      LOGN("Couldn't open PNG file: %s", error_message); -    goto err; +    return 1;    }    LisPng *png = LisPng_decode(png_file); +  if (!png) { +    LOG0("Couldn't decode PNG"); +    return 1; +  } +    LisPng_dump_ppm(png);    LisPng_destroy(png);    if (fclose(png_file) != 0) {      const char *error_message = strerror(errno);      LOGN("Couldn't close PNG file: %s", error_message); -    goto err; +    return 1;    }    return 0; -err: -  return 1;  }  | 
