mirror of
https://github.com/dankamongmen/notcurses.git
synced 2024-11-18 03:25:55 +00:00
cell_duplicate_far() fix length issue
This commit is contained in:
parent
7ac3f68f4e
commit
2656cad07a
@ -385,9 +385,9 @@ static inline char*
|
|||||||
pool_egc_copy(const egcpool* e, const cell* c){
|
pool_egc_copy(const egcpool* e, const cell* c){
|
||||||
char* ret;
|
char* ret;
|
||||||
if(cell_simple_p(c)){
|
if(cell_simple_p(c)){
|
||||||
if( (ret = (char*)malloc(2)) ){
|
if( (ret = (char*)malloc(sizeof(c->gcluster) + 1)) ){
|
||||||
ret[0] = c->gcluster;
|
memset(ret, 0, sizeof(c->gcluster) + 1);
|
||||||
ret[1] = '\0';
|
memcpy(ret, &c->gcluster, sizeof(c->gcluster));
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
ret = strdup(egcpool_extended_gcluster(e, c));
|
ret = strdup(egcpool_extended_gcluster(e, c));
|
||||||
@ -599,7 +599,7 @@ cell_duplicate_far(egcpool* tpool, cell* targ, const ncplane* splane, const cell
|
|||||||
targ->channels = c->channels;
|
targ->channels = c->channels;
|
||||||
if(cell_simple_p(c)){
|
if(cell_simple_p(c)){
|
||||||
targ->gcluster = c->gcluster;
|
targ->gcluster = c->gcluster;
|
||||||
return !!c->gcluster;
|
return strnlen((char*)&c->gcluster, sizeof(c->gcluster));
|
||||||
}
|
}
|
||||||
assert(splane);
|
assert(splane);
|
||||||
const char* egc = extended_gcluster(splane, c);
|
const char* egc = extended_gcluster(splane, c);
|
||||||
|
@ -418,8 +418,10 @@ TEST_CASE("Wide") {
|
|||||||
free(egc);
|
free(egc);
|
||||||
cell cl = CELL_TRIVIAL_INITIALIZER, cr = CELL_TRIVIAL_INITIALIZER;
|
cell cl = CELL_TRIVIAL_INITIALIZER, cr = CELL_TRIVIAL_INITIALIZER;
|
||||||
CHECK(3 == ncplane_at_yx_cell(n_, 1, 1, &cl));
|
CHECK(3 == ncplane_at_yx_cell(n_, 1, 1, &cl));
|
||||||
REQUIRE(cell_extended_gcluster(n_, &cl));
|
egc = cell_strdup(n_, &cl);
|
||||||
CHECK(0 == strcmp("六", extended_gcluster(n_, &cl)));
|
REQUIRE(nullptr != egc);
|
||||||
|
CHECK(0 == strcmp("六", egc));
|
||||||
|
free(egc);
|
||||||
CHECK(0 == ncplane_at_yx_cell(n_, 1, 2, &cr));
|
CHECK(0 == ncplane_at_yx_cell(n_, 1, 2, &cr));
|
||||||
REQUIRE(cell_simple_p(&cr));
|
REQUIRE(cell_simple_p(&cr));
|
||||||
CHECK(0 == cr.gcluster);
|
CHECK(0 == cr.gcluster);
|
||||||
|
Loading…
Reference in New Issue
Block a user