Browse Source

Merge pull request #307 from mscdex/master

misc fixes
v1.x
Nathan Rajlich 12 years ago
parent
commit
89e50d3fd6
  1. 2
      src/Canvas.cc
  2. 6
      src/Image.cc

2
src/Canvas.cc

@ -132,7 +132,7 @@ toBuffer(void *c, const uint8_t *data, unsigned len) {
// Olaf: grow buffer // Olaf: grow buffer
if (closure->len + len > closure->max_len) { if (closure->len + len > closure->max_len) {
uint8_t *data; uint8_t *data;
unsigned max = closure->max_len; unsigned max;
// round to the nearest multiple of 1024 bytes // round to the nearest multiple of 1024 bytes
max = (closure->max_len + len + 1023) & ~1023; max = (closure->max_len + len + 1023) & ~1023;

6
src/Image.cc

@ -375,7 +375,10 @@ Image::loadSurface() {
FILE *stream = fopen(filename, "r"); FILE *stream = fopen(filename, "r");
if (!stream) return CAIRO_STATUS_READ_ERROR; if (!stream) return CAIRO_STATUS_READ_ERROR;
uint8_t buf[5]; uint8_t buf[5];
if (1 != fread(&buf, 5, 1, stream)) return CAIRO_STATUS_READ_ERROR; if (1 != fread(&buf, 5, 1, stream)) {
fclose(stream);
return CAIRO_STATUS_READ_ERROR;
}
fseek(stream, 0, SEEK_SET); fseek(stream, 0, SEEK_SET);
// png // png
@ -394,6 +397,7 @@ Image::loadSurface() {
if (isJPEG(buf)) return loadJPEG(stream); if (isJPEG(buf)) return loadJPEG(stream);
#endif #endif
fclose(stream);
return CAIRO_STATUS_READ_ERROR; return CAIRO_STATUS_READ_ERROR;
} }

Loading…
Cancel
Save