| Index: examples/thumb.c | 
| diff --git a/examples/thumb.c b/examples/thumb.c | 
| index 3dc360e3a1ef036df3d84ac9caefbe5bc9575e1d..2718a0c44468e493c72d4409a0b545ed60b9fbed 100644 | 
| --- a/examples/thumb.c | 
| +++ b/examples/thumb.c | 
| @@ -47,7 +47,7 @@ int main (int argc, char **argv) { | 
| int fd; | 
| uint32_t id = 0; | 
| uint64_t filesize; | 
| -  char *imagedata = NULL; | 
| +  uint8_t *imagedata = NULL; | 
| char *path = NULL; | 
| char *rest; | 
| struct stat statbuff; | 
| @@ -81,8 +81,8 @@ int main (int argc, char **argv) { | 
| perror("stat"); | 
| exit(1); | 
| } | 
| -  filesize = statbuff.st_size; | 
| -  imagedata = malloc(filesize); | 
| +  filesize = (uint64_t) statbuff.st_size; | 
| +  imagedata = malloc(filesize * sizeof(uint16_t)); | 
|  | 
| #ifdef __WIN32__ | 
| if ( (fd = open(path, O_RDONLY|O_BINARY) == -1) ) { | 
| @@ -91,9 +91,9 @@ int main (int argc, char **argv) { | 
| #endif | 
| printf("Couldn't open image file %s (%s)\n",path,strerror(errno)); | 
| return 1; | 
| -  } else { | 
| -    ret = read(fd, imagedata, filesize); | 
| -    if (ret == -1) perror("read thumb data"); | 
| +  } | 
| +  else { | 
| +    read(fd, imagedata, filesize); | 
| close(fd); | 
| } | 
|  | 
| @@ -105,9 +105,16 @@ int main (int argc, char **argv) { | 
| } | 
|  | 
| LIBMTP_filesampledata_t *thumb = LIBMTP_new_filesampledata_t(); | 
| -  thumb->data = imagedata; | 
| + | 
| +  int i; | 
| +  thumb->data = malloc(sizeof(uint16_t) * filesize); | 
| +  for (i = 0; i < filesize; i++) { | 
| +    thumb->data[i] = imagedata[i]; | 
| +  } | 
| + | 
| thumb->size = filesize; | 
| thumb->filetype = LIBMTP_FILETYPE_JPEG; | 
| + | 
| ret = LIBMTP_Send_Representative_Sample(device,id,thumb); | 
| if (ret != 0) { | 
| printf("Couldn't send thumbnail\n"); | 
| @@ -115,6 +122,7 @@ int main (int argc, char **argv) { | 
| LIBMTP_Clear_Errorstack(device); | 
| } | 
|  | 
| +  free(imagedata); | 
| LIBMTP_destroy_filesampledata_t(thumb); | 
|  | 
| LIBMTP_Release_Device(device); | 
|  |