mirror of
https://github.com/go-vgo/robotgo.git
synced 2025-05-31 06:13: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
|
||||
if (result != NULL) {
|
||||
// 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);
|
||||
|
||||
if (name != NULL) { return name; }
|
||||
@ -658,8 +666,17 @@ char* get_title_by_hand(MData m_data){
|
||||
// Check result value
|
||||
if (result != NULL) {
|
||||
// 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);
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user