mirror of
https://github.com/Hopiu/fabric.js.git
synced 2026-05-03 03:24:42 +00:00
Don't create image data Buffer when data is empty
Fix for segmentation fault when image couldn't be loaded
This commit is contained in:
parent
91897de495
commit
7515fcedbe
1 changed files with 6 additions and 4 deletions
10
src/node.js
10
src/node.js
|
|
@ -71,10 +71,12 @@
|
|||
|
||||
fabric.util.loadImage = function(url, callback, context) {
|
||||
function createImageAndCallBack(data) {
|
||||
img.src = new Buffer(data, 'binary');
|
||||
// preserving original url, which seems to be lost in node-canvas
|
||||
img._src = url;
|
||||
callback && callback.call(context, img);
|
||||
if (data) {
|
||||
img.src = new Buffer(data, 'binary');
|
||||
// preserving original url, which seems to be lost in node-canvas
|
||||
img._src = url;
|
||||
callback && callback.call(context, img);
|
||||
}
|
||||
}
|
||||
var img = new Image();
|
||||
if (url && (url instanceof Buffer || url.indexOf('data') === 0)) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue