Skip to content

Commit 57d919a

Browse files
Sakari369zbjornson
authored andcommittedMay 30, 2020
Move getSafeBufSize() under #ifdef HAVE_JPEG, removes compiler warning of unused function removal
1 parent 4af2efd commit 57d919a

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed
 

‎src/Canvas.cc

+5-7
Original file line numberDiff line numberDiff line change
@@ -314,12 +314,6 @@ static void parseJPEGArgs(Local<Value> arg, JpegClosure& jpegargs) {
314314
}
315315
#endif
316316

317-
static uint32_t getSafeBufSize(Canvas* canvas) {
318-
// Don't allow the buffer size to exceed the size of the canvas (#674)
319-
// TODO not sure if this is really correct, but it fixed #674
320-
return (std::min)(canvas->getWidth() * canvas->getHeight() * 4, static_cast<int>(PAGE_SIZE));
321-
}
322-
323317
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 16, 0)
324318

325319
static inline void setPdfMetaStr(cairo_surface_t* surf, Local<Object> opts,
@@ -679,6 +673,11 @@ NAN_METHOD(Canvas::StreamPDFSync) {
679673
*/
680674

681675
#ifdef HAVE_JPEG
676+
static uint32_t getSafeBufSize(Canvas* canvas) {
677+
// Don't allow the buffer size to exceed the size of the canvas (#674)
678+
// TODO not sure if this is really correct, but it fixed #674
679+
return (std::min)(canvas->getWidth() * canvas->getHeight() * 4, static_cast<int>(PAGE_SIZE));
680+
}
682681

683682
NAN_METHOD(Canvas::StreamJPEGSync) {
684683
if (!info[1]->IsFunction())
@@ -698,7 +697,6 @@ NAN_METHOD(Canvas::StreamJPEGSync) {
698697
}
699698
return;
700699
}
701-
702700
#endif
703701

704702
char *

0 commit comments

Comments
 (0)