/* read the script’s output */
int conv_size = 65535;
- char *converted = smalloc(conv_size);
+ char *converted = scalloc(conv_size, 1);
int read_bytes = 0, ret;
do {
if (read_bytes == conv_size) {
wait(&status);
if (!WIFEXITED(status)) {
fprintf(stderr, "Child did not terminate normally, using old config file (will lead to broken behaviour)\n");
+ FREE(converted);
return NULL;
}
fprintf(stderr, "# i3 config file (v4)\n");
/* TODO: nag the user with a message to include a hint for i3 in their config file */
}
+ FREE(converted);
return NULL;
}
FREE(current_config);
current_config = scalloc(stbuf.st_size + 1, 1);
- fread(current_config, 1, stbuf.st_size, fstr);
+ if ((ssize_t)fread(current_config, 1, stbuf.st_size, fstr) != stbuf.st_size) {
+ die("Could not fread: %s\n", strerror(errno));
+ }
rewind(fstr);
bool invalid_sets = false;
/* Then, allocate a new buffer and copy the file over to the new one,
* but replace occurrences of our variables */
char *walk = buf, *destwalk;
- char *new = smalloc(stbuf.st_size + extra_bytes + 1);
+ char *new = scalloc(stbuf.st_size + extra_bytes + 1, 1);
destwalk = new;
while (walk < (buf + stbuf.st_size)) {
/* Find the next variable */
int version = detect_version(buf);
if (version == 3) {
/* We need to convert this v3 configuration */
- char *converted = migrate_config(new, stbuf.st_size);
+ char *converted = migrate_config(new, strlen(new));
if (converted != NULL) {
ELOG("\n");
ELOG("****************************************************************\n");