overflow errors
This commit is contained in:
@@ -28,45 +28,42 @@
|
||||
struct editorConfig E;
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
char * splash_screen = strdup(getenv("HOME"));
|
||||
int home_path_len = (int) strlen(splash_screen);
|
||||
char * splash_screen_relative_path = strdup("/.beluga/assets/beluga.txt");
|
||||
int splash_screen_relative_path_len = (int) strlen(splash_screen_relative_path);
|
||||
|
||||
signal(SIGPIPE, SIG_IGN); // don't die on broken pipe, just get EPIPE from write()
|
||||
|
||||
enableRawMode();
|
||||
initEditor();
|
||||
EditorPane *active = splitScreenGetActivePane();
|
||||
struct buffer_t *buf;
|
||||
|
||||
splash_screen = realloc(splash_screen, sizeof(char) * (home_path_len + splash_screen_relative_path_len + 1));
|
||||
strcat(splash_screen, "/.beluga/assets/beluga.txt");
|
||||
free(splash_screen_relative_path);
|
||||
|
||||
appDebug("splash : %s\n", splash_screen);
|
||||
active->buffer_id = bufferCreate(splash_screen, READ_ONLY);
|
||||
|
||||
if (argc >= 2) {
|
||||
if (E.constantes.LSP) {
|
||||
|
||||
// Get HOME with NULL check
|
||||
const char *home = getenv("HOME");
|
||||
if (!home) {
|
||||
fprintf(stderr, "Error: HOME environment variable not set\n");
|
||||
return 1;
|
||||
}
|
||||
active->buffer_id = bufferCreate(argv[1], READ_AND_WRITE);
|
||||
|
||||
buf = &E.buffers[active->buffer_id];
|
||||
// Allocate and build splash screen path safely
|
||||
char *splash_screen;
|
||||
if (asprintf(&splash_screen, "%s/.beluga/assets/beluga.txt", home) == -1) {
|
||||
fprintf(stderr, "Error: Failed to allocate splash screen path\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
appDebug("peoject root : %s\n", dirname(buf->fullname));
|
||||
signal(SIGPIPE, SIG_IGN);
|
||||
enableRawMode();
|
||||
initEditor();
|
||||
|
||||
EditorPane *active = splitScreenGetActivePane();
|
||||
struct buffer_t *buf;
|
||||
|
||||
}
|
||||
free(splash_screen);
|
||||
appDebug("splash : %s\n", splash_screen);
|
||||
active->buffer_id = bufferCreate(splash_screen, READ_ONLY);
|
||||
|
||||
editorSetStatusMessage("HELP: Ctrl-x Ctrl-s = save | Ctrl-x Ctrl-c = quit");
|
||||
if (argc >= 2) {
|
||||
active->buffer_id = bufferCreate(argv[1], READ_AND_WRITE);
|
||||
buf = &E.buffers[active->buffer_id];
|
||||
appDebug("project root : %s\n", dirname(buf->fullname));
|
||||
}
|
||||
|
||||
while (1) {
|
||||
editorRefreshScreen();
|
||||
editorProcessKeypress();
|
||||
}
|
||||
return 0;
|
||||
free(splash_screen); // Now guaranteed safe
|
||||
|
||||
editorSetStatusMessage("HELP: Ctrl-x Ctrl-s = save | Ctrl-x Ctrl-c = quit");
|
||||
while (1) {
|
||||
editorRefreshScreen();
|
||||
editorProcessKeypress();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user