Skip to content
Snippets Groups Projects
Commit 32fb9b77 authored by Deucе's avatar Deucе :ok_hand_tone4:
Browse files

More malloc() return checks

parent 20165689
Branches
Tags
No related merge requests found
Pipeline #7025 passed
...@@ -461,28 +461,30 @@ void docopy(void) ...@@ -461,28 +461,30 @@ void docopy(void)
case CIOLIB_BUTTON_1_DRAG_END: case CIOLIB_BUTTON_1_DRAG_END:
lines=abs(mevent.endy-mevent.starty)+1; lines=abs(mevent.endy-mevent.starty)+1;
copybuf=malloc(((endy-starty+1)*(endx-startx+1)+1+lines*2)*4); copybuf=malloc(((endy-starty+1)*(endx-startx+1)+1+lines*2)*4);
outpos=0; if (copybuf) {
for(y=starty-1;y<endy;y++) { outpos=0;
for(x=startx-1;x<endx;x++) { for(y=starty-1;y<endy;y++) {
size_t outlen; for(x=startx-1;x<endx;x++) {
uint8_t *utf8str; size_t outlen;
char ch; uint8_t *utf8str;
char ch;
ch = screen->vmem[(y*api->scrn_width+x)].ch ? screen->vmem[(y*api->scrn_width+x)].ch : ' ';
utf8str = cp_to_utf8(conio_fontdata[screen->vmem[(y*api->scrn_width+x)].font].cp, &ch, 1, &outlen); ch = screen->vmem[(y*api->scrn_width+x)].ch ? screen->vmem[(y*api->scrn_width+x)].ch : ' ';
if (utf8str == NULL) utf8str = cp_to_utf8(conio_fontdata[screen->vmem[(y*api->scrn_width+x)].font].cp, &ch, 1, &outlen);
continue; if (utf8str == NULL)
memcpy(copybuf + outpos, utf8str, outlen); continue;
outpos += outlen; memcpy(copybuf + outpos, utf8str, outlen);
outpos += outlen;
}
#ifdef _WIN32
copybuf[outpos++]='\r';
#endif
copybuf[outpos++]='\n';
} }
#ifdef _WIN32 copybuf[outpos]=0;
copybuf[outpos++]='\r'; copytext(copybuf, strlen(copybuf));
#endif free(copybuf);
copybuf[outpos++]='\n';
} }
copybuf[outpos]=0;
copytext(copybuf, strlen(copybuf));
free(copybuf);
restorescreen(screen); restorescreen(screen);
freescreen(screen); freescreen(screen);
freescreen(sbuffer); freescreen(sbuffer);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment