summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKim Woelders <kim@woelders.dk>2018-03-10 19:48:51 +0100
committerKim Woelders <kim@woelders.dk>2018-03-10 20:25:58 +0100
commitd0da3117e9b2a1599fa08fd74f8ca4bc9be42fc8 (patch)
tree42d715bd7da02db823ad7a47a33c97a6b50f7036
parent4d6ff056ef1e463498c0873cae6345e8262195c3 (diff)
downloadimlib2-d0da3117e9b2a1599fa08fd74f8ca4bc9be42fc8.tar.gz
imlib2_conv.c: Fix gcc8 warning
imlib2_conv.c: In function ‘main’: imlib2_conv.c:64:14: error: ‘strncpy’ specified bound depends on the length of the source argument [-Werror=stringop-overflow=] strncpy(p, dot, (strlen(dot) < 9) ? strlen(dot) : 8); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ imlib2_conv.c:64:31: note: length computed here strncpy(p, dot, (strlen(dot) < 9) ? strlen(dot) : 8); ^~~~~~~~~~~
-rw-r--r--src/bin/imlib2_conv.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/src/bin/imlib2_conv.c b/src/bin/imlib2_conv.c
index 975a4e0..0148079 100644
--- a/src/bin/imlib2_conv.c
+++ b/src/bin/imlib2_conv.c
@@ -59,11 +59,9 @@ main(int argc, char **argv)
char *p, *q;
/* max length of 8 for format name. seems reasonable. */
- q = p = malloc(9);
- memset(p, 0, 8);
- strncpy(p, dot, (strlen(dot) < 9) ? strlen(dot) : 8);
+ p = strndup(dot, 8);
/* Imlib2 only recognizes lowercase formats. convert it. */
- for (q[8] = 0; *q; q++)
+ for (q = p; *q; q++)
*q = tolower(*q);
imlib_image_set_format(p);
free(p);