File: path_max.patch

package info (click to toggle)
plutovg 1.3.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,280 kB
  • sloc: ansic: 18,914; sh: 10; makefile: 6
file content (26 lines) | stat: -rw-r--r-- 937 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
26
Description: fix for platforms that don't define PATH_MAX
Author: Sébastien Noel <sebastien@twolife.be>
Forwarded: TODO
--- a/source/plutovg-font.c
+++ b/source/plutovg-font.c
@@ -1006,8 +1006,10 @@
     while((entry = readdir(dir)) != NULL) {
         if(strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0)
             continue;
-        char path[PATH_MAX];
-        snprintf(path, sizeof(path), "%s/%s", dirname, entry->d_name);
+        char *path;
+        size_t len = strlen(dirname) + 1 + strlen(entry->d_name) + 1;
+        path = malloc(len);
+        snprintf(path, len, "%s/%s", dirname, entry->d_name);
 
         struct stat st;
         if(stat(path, &st) == -1)
@@ -1017,6 +1019,7 @@
         } else if(S_ISREG(st.st_mode) && plutovg_font_face_supports_file(path)) {
             num_faces += plutovg_font_face_cache_load_file(cache, path);
         }
+        free(path);
     }
 
     closedir(dir);