mirror of
https://github.com/go-vgo/robotgo.git
synced 2025-06-01 14:43:55 +00:00
Fixes #258: char* arrays in C not being copied correctly
This commit is contained in:
parent
9483a7f010
commit
a38bb946c1
@ -646,7 +646,15 @@ char* get_title_by_hand(MData m_data){
|
|||||||
// Check result value
|
// Check result value
|
||||||
if (result != NULL) {
|
if (result != NULL) {
|
||||||
// Convert result to a string
|
// Convert result to a string
|
||||||
char *name = (char*)result;
|
char *name = (char*)calloc(strlen(result)+1, sizeof(char*));
|
||||||
|
char *rptr = (char*)result;
|
||||||
|
char *nptr = name;
|
||||||
|
while (*rptr) {
|
||||||
|
*nptr = *rptr;
|
||||||
|
nptr++;
|
||||||
|
rptr++;
|
||||||
|
}
|
||||||
|
*nptr = '\0';
|
||||||
XFree(result);
|
XFree(result);
|
||||||
|
|
||||||
if (name != NULL) { return name; }
|
if (name != NULL) { return name; }
|
||||||
@ -658,8 +666,17 @@ char* get_title_by_hand(MData m_data){
|
|||||||
// Check result value
|
// Check result value
|
||||||
if (result != NULL) {
|
if (result != NULL) {
|
||||||
// Convert result to a string
|
// Convert result to a string
|
||||||
char *name = (char*)result;
|
char *name = (char*)calloc(strlen(result)+1, sizeof(char*));
|
||||||
|
char *rptr = (char*)result;
|
||||||
|
char *nptr = name;
|
||||||
|
while (*rptr) {
|
||||||
|
*nptr = *rptr;
|
||||||
|
nptr++;
|
||||||
|
rptr++;
|
||||||
|
}
|
||||||
|
*nptr = '\0';
|
||||||
XFree(result);
|
XFree(result);
|
||||||
|
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user