File: use_strdup.patch

package info (click to toggle)
libkibi 0.1.1-2.1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 1,552 kB
  • sloc: sh: 11,613; ansic: 1,209; makefile: 25
file content (25 lines) | stat: -rw-r--r-- 925 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
Description: Fix ftbfs with GCC
 Use strdup() instead of using malloc() and then copying the full length
 of the string.

Author: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
Bug-Debian: https://bugs.debian.org/925747

---

--- libkibi-0.1.1.orig/kibi/kibi.c
+++ libkibi-0.1.1/kibi/kibi.c
@@ -313,12 +313,11 @@ static char *get_xdg_config_home(void) {
     xdg_config_home = getenv("XDG_CONFIG_HOME");
     if(xdg_config_home != NULL && strlen(xdg_config_home) > 0) {
         length = strlen(xdg_config_home) + 1;
-        result = malloc(length);
+        result = strdup(xdg_config_home);
         if(unlikely(result == NULL)) {
             malloc_error(length);
             return NULL;
         }
-        strncpy(result, xdg_config_home, length);
     } else { // xdg_config_home == NULL || strlen(xdg_config_home) == 0
         // Use $HOME/.config if XDG_CONFIG_HOME is not defined.
         home = getenv("HOME");