Skip to content

Commit

Permalink
Fix Graphics.createImage if the last character is a newline
Browse files Browse the repository at this point in the history
            Graphics: Fix issue if drawImage given a non-image
  • Loading branch information
gfwilliams committed Jun 6, 2023
1 parent 85872e6 commit 49c916a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 2 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
2v19 : Fix Object.values/entries for numeric keys after 2v18 regression (fix #2375)
nRF52: for SD>5 use static buffers for advertising and scan response data (#2367)
Bangle.js: Add Bangle.showRecoveryMenu, and if storage is corrupt then show it rather than automatically doing factory reset
Fix Graphics.createImage if the last character is a newline
Graphics: Fix issue if drawImage given a non-image

2v18 : Fix drawString with setClipRect with 90/270-degree rotation (fix #2343)
Pico/Wifi: Enabled JIT compiler
Expand Down
5 changes: 2 additions & 3 deletions libs/graphics/jswrap_graphics.c
Original file line number Diff line number Diff line change
Expand Up @@ -789,15 +789,14 @@ JsVar *jswrap_graphics_createImage(JsVar *data) {
} else {
x=0;
y++;
if (y>height) height=y;
if (y+1>height) height=y+1;
}
} else {
x++;
if (x>width) width=x;
}
}
if (x) height++;
if (height && ch=="\n") height--; // if the last char was a newline, ignore it
if (height && ch=='\n') height--; // if the last char was a newline, ignore it
jsvStringIteratorFree(&it);
// Sorted - now create the object, set it up and create the buffer
JsVar *img = jsvNewObject();
Expand Down
1 change: 1 addition & 0 deletions src/jsvar.c
Original file line number Diff line number Diff line change
Expand Up @@ -2249,6 +2249,7 @@ size_t jsvGetArrayBufferLength(const JsVar *arrayBuffer) {

/** Get the String the contains the data for this arrayBuffer. Is ok with being passed a String in the first place. Offset is the offset in the backing string of this arraybuffer. */
JsVar *jsvGetArrayBufferBackingString(JsVar *arrayBuffer, uint32_t *offset) {
if (!arrayBuffer) return 0;
jsvLockAgain(arrayBuffer);
if (offset) *offset = 0;
while (jsvIsArrayBuffer(arrayBuffer)) {
Expand Down

0 comments on commit 49c916a

Please sign in to comment.