summaryrefslogtreecommitdiff
path: root/legacy/efreet/src/lib/efreet_desktop_command.c
diff options
context:
space:
mode:
authorSebastian Dransfeld <sd@tango.flipp.net>2010-08-03 20:46:36 +0000
committerSebastian Dransfeld <sd@tango.flipp.net>2010-08-03 20:46:36 +0000
commitb197b55abc4960ba1ba2d50dd24fcc76ac0e1876 (patch)
tree25260761e3b178a8f0d5e0091e076186abbf2e40 /legacy/efreet/src/lib/efreet_desktop_command.c
parentbeacf6f9764e8cd13d6365f8c0c5516dae0b8d57 (diff)
Check return NULL
SVN revision: 50786
Diffstat (limited to 'legacy/efreet/src/lib/efreet_desktop_command.c')
-rw-r--r--legacy/efreet/src/lib/efreet_desktop_command.c44
1 files changed, 39 insertions, 5 deletions
diff --git a/legacy/efreet/src/lib/efreet_desktop_command.c b/legacy/efreet/src/lib/efreet_desktop_command.c
index 374431c..4ce9c1e 100644
--- a/legacy/efreet/src/lib/efreet_desktop_command.c
+++ b/legacy/efreet/src/lib/efreet_desktop_command.c
@@ -248,8 +248,11 @@ efreet_desktop_command_progress_get(Efreet_Desktop *desktop, Eina_List *files,
248 Eina_List *execs; 248 Eina_List *execs;
249 249
250 execs = efreet_desktop_command_build(command); 250 execs = efreet_desktop_command_build(command);
251 ret = efreet_desktop_command_execs_process(command, execs); 251 if (execs)
252 eina_list_free(execs); 252 {
253 ret = efreet_desktop_command_execs_process(command, execs);
254 eina_list_free(execs);
255 }
253 efreet_desktop_command_free(command); 256 efreet_desktop_command_free(command);
254 } 257 }
255 258
@@ -399,6 +402,7 @@ efreet_desktop_command_build(Efreet_Desktop_Command *command)
399 { 402 {
400 exec = efreet_desktop_command_append_single(exec, &size, 403 exec = efreet_desktop_command_append_single(exec, &size,
401 &len, file, *p); 404 &len, file, *p);
405 if (!exec) goto error;
402 file_added = 1; 406 file_added = 1;
403 } 407 }
404 break; 408 break;
@@ -410,20 +414,24 @@ efreet_desktop_command_build(Efreet_Desktop_Command *command)
410 { 414 {
411 exec = efreet_desktop_command_append_multiple(exec, &size, 415 exec = efreet_desktop_command_append_multiple(exec, &size,
412 &len, command, *p); 416 &len, command, *p);
417 if (!exec) goto error;
413 file_added = 1; 418 file_added = 1;
414 } 419 }
415 break; 420 break;
416 case 'i': 421 case 'i':
417 exec = efreet_desktop_command_append_icon(exec, &size, &len, 422 exec = efreet_desktop_command_append_icon(exec, &size, &len,
418 command->desktop); 423 command->desktop);
424 if (!exec) goto error;
419 break; 425 break;
420 case 'c': 426 case 'c':
421 exec = efreet_desktop_command_append_quoted(exec, &size, &len, 427 exec = efreet_desktop_command_append_quoted(exec, &size, &len,
422 command->desktop->name); 428 command->desktop->name);
429 if (!exec) goto error;
423 break; 430 break;
424 case 'k': 431 case 'k':
425 exec = efreet_desktop_command_append_quoted(exec, &size, &len, 432 exec = efreet_desktop_command_append_quoted(exec, &size, &len,
426 command->desktop->orig_path); 433 command->desktop->orig_path);
434 if (!exec) goto error;
427 break; 435 break;
428 case 'v': 436 case 'v':
429 case 'm': 437 case 'm':
@@ -470,6 +478,7 @@ efreet_desktop_command_build(Efreet_Desktop_Command *command)
470 exec[len++] = ' '; 478 exec[len++] = ' ';
471 exec = efreet_desktop_command_append_multiple(exec, &size, 479 exec = efreet_desktop_command_append_multiple(exec, &size,
472 &len, command, 'F'); 480 &len, command, 'F');
481 if (!exec) goto error;
473 file_added = 1; 482 file_added = 1;
474 } 483 }
475#endif 484#endif
@@ -514,6 +523,7 @@ efreet_desktop_command_append_quoted(char *dest, int *size, int *len, char *src)
514{ 523{
515 if (!src) return dest; 524 if (!src) return dest;
516 dest = efreet_string_append(dest, size, len, "'"); 525 dest = efreet_string_append(dest, size, len, "'");
526 if (!dest) return NULL;
517 527
518 /* single quotes in src need to be escaped */ 528 /* single quotes in src need to be escaped */
519 if (strchr(src, '\'')) 529 if (strchr(src, '\''))
@@ -523,16 +533,24 @@ efreet_desktop_command_append_quoted(char *dest, int *size, int *len, char *src)
523 while (*p) 533 while (*p)
524 { 534 {
525 if (*p == '\'') 535 if (*p == '\'')
536 {
526 dest = efreet_string_append(dest, size, len, "\'\\\'"); 537 dest = efreet_string_append(dest, size, len, "\'\\\'");
538 if (!dest) return NULL;
539 }
527 540
528 dest = efreet_string_append_char(dest, size, len, *p); 541 dest = efreet_string_append_char(dest, size, len, *p);
542 if (!dest) return NULL;
529 p++; 543 p++;
530 } 544 }
531 } 545 }
532 else 546 else
547 {
533 dest = efreet_string_append(dest, size, len, src); 548 dest = efreet_string_append(dest, size, len, src);
549 if (!dest) return NULL;
550 }
534 551
535 dest = efreet_string_append(dest, size, len, "'"); 552 dest = efreet_string_append(dest, size, len, "'");
553 if (!dest) return NULL;
536 554
537 return dest; 555 return dest;
538} 556}
@@ -553,10 +571,14 @@ efreet_desktop_command_append_multiple(char *dest, int *size, int *len,
553 if (first) 571 if (first)
554 first = 0; 572 first = 0;
555 else 573 else
574 {
556 dest = efreet_string_append_char(dest, size, len, ' '); 575 dest = efreet_string_append_char(dest, size, len, ' ');
576 if (!dest) return NULL;
577 }
557 578
558 dest = efreet_desktop_command_append_single(dest, size, len, 579 dest = efreet_desktop_command_append_single(dest, size, len,
559 file, tolower(type)); 580 file, tolower(type));
581 if (!dest) return NULL;
560 } 582 }
561 583
562 return dest; 584 return dest;
@@ -591,6 +613,7 @@ efreet_desktop_command_append_single(char *dest, int *size, int *len,
591 if (!str) return dest; 613 if (!str) return dest;
592 614
593 dest = efreet_desktop_command_append_quoted(dest, size, len, str); 615 dest = efreet_desktop_command_append_quoted(dest, size, len, str);
616 if (!dest) return NULL;
594 617
595 return dest; 618 return dest;
596} 619}
@@ -602,7 +625,9 @@ efreet_desktop_command_append_icon(char *dest, int *size, int *len,
602 if (!desktop->icon || !desktop->icon[0]) return dest; 625 if (!desktop->icon || !desktop->icon[0]) return dest;
603 626
604 dest = efreet_string_append(dest, size, len, "--icon "); 627 dest = efreet_string_append(dest, size, len, "--icon ");
628 if (!dest) return NULL;
605 dest = efreet_desktop_command_append_quoted(dest, size, len, desktop->icon); 629 dest = efreet_desktop_command_append_quoted(dest, size, len, desktop->icon);
630 if (!dest) return NULL;
606 631
607 return dest; 632 return dest;
608} 633}
@@ -667,6 +692,7 @@ efreet_desktop_command_file_process(Efreet_Desktop_Command *command, const char
667 else 692 else
668 { 693 {
669 char *absol = efreet_desktop_command_path_absolute(file); 694 char *absol = efreet_desktop_command_path_absolute(file);
695 if (!absol) goto error;
670 /* process local uri/path */ 696 /* process local uri/path */
671 if (command->flags & EFREET_DESKTOP_EXEC_FLAG_FULLPATH) 697 if (command->flags & EFREET_DESKTOP_EXEC_FLAG_FULLPATH)
672 f->fullpath = strdup(absol); 698 f->fullpath = strdup(absol);
@@ -687,6 +713,9 @@ efreet_desktop_command_file_process(Efreet_Desktop_Command *command, const char
687 INF(" file: %s", f->file); 713 INF(" file: %s", f->file);
688#endif 714#endif
689 return f; 715 return f;
716error:
717 IF_FREE(f);
718 return NULL;
690} 719}
691 720
692/** 721/**
@@ -774,9 +803,12 @@ efreet_desktop_cb_download_complete(void *data, const char *file __UNUSED__,
774 Eina_List *execs; 803 Eina_List *execs;
775 804
776 execs = efreet_desktop_command_build(f->command); 805 execs = efreet_desktop_command_build(f->command);
777 /* TODO: Need to handle the return value from efreet_desktop_command_execs_process */ 806 if (execs)
778 efreet_desktop_command_execs_process(f->command, execs); 807 {
779 eina_list_free(execs); 808 /* TODO: Need to handle the return value from efreet_desktop_command_execs_process */
809 efreet_desktop_command_execs_process(f->command, execs);
810 eina_list_free(execs);
811 }
780 efreet_desktop_command_free(f->command); 812 efreet_desktop_command_free(f->command);
781 } 813 }
782} 814}
@@ -823,7 +855,9 @@ efreet_desktop_command_path_absolute(const char *path)
823 len = strlen(buf); 855 len = strlen(buf);
824 856
825 if (buf[len-1] != '/') buf = efreet_string_append(buf, &size, &len, "/"); 857 if (buf[len-1] != '/') buf = efreet_string_append(buf, &size, &len, "/");
858 if (!buf) return NULL;
826 buf = efreet_string_append(buf, &size, &len, path); 859 buf = efreet_string_append(buf, &size, &len, path);
860 if (!buf) return NULL;
827 861
828 return buf; 862 return buf;
829 } 863 }