| 88 | } |
| 89 | |
| 90 | static char *jl_read(const char *path) { |
| 91 | FILE *file = cbm_fopen(path, "rb"); |
| 92 | if (!file || fseek(file, 0, SEEK_END) != 0) { |
| 93 | if (file) { |
| 94 | fclose(file); |
| 95 | } |
| 96 | return NULL; |
| 97 | } |
| 98 | long size = ftell(file); |
| 99 | if (size < 0 || fseek(file, 0, SEEK_SET) != 0) { |
| 100 | fclose(file); |
| 101 | return NULL; |
| 102 | } |
| 103 | char *content = malloc((size_t)size + 1U); |
| 104 | if (!content) { |
| 105 | fclose(file); |
| 106 | return NULL; |
| 107 | } |
| 108 | size_t read_count = fread(content, 1U, (size_t)size, file); |
| 109 | int failed = ferror(file); |
| 110 | fclose(file); |
| 111 | if (read_count != (size_t)size || failed) { |
| 112 | free(content); |
| 113 | return NULL; |
| 114 | } |
| 115 | content[read_count] = '\0'; |
| 116 | return content; |
| 117 | } |
| 118 | |
| 119 | static int jl_failed_unchanged(const char *path, const char *original, |
| 120 | const char *const *object_path, size_t path_len, const char *key, |
no test coverage detected