comparison libmpdemux/demuxer.c @ 3150:8dae87740d33

bad malloc+strcpy => strdup
author arpi
date Tue, 27 Nov 2001 00:42:39 +0000
parents 637e540831b9
children c42e6759c82b
comparison
equal deleted inserted replaced
3149:fc5a2369696e 3150:8dae87740d33
1 //=================== DEMUXER v2.5 ========================= 1 //=================== DEMUXER v2.5 =========================
2 2
3 #include <stdio.h> 3 #include <stdio.h>
4 #include <stdlib.h> 4 #include <stdlib.h>
5 #include <string.h>
5 #include <unistd.h> 6 #include <unistd.h>
6 7
7 #include <sys/types.h> 8 #include <sys/types.h>
8 #include <sys/stat.h> 9 #include <sys/stat.h>
9 10
652 if (info->name) 653 if (info->name)
653 { 654 {
654 mp_msg(MSGT_DEMUX, MSGL_WARN, "Demuxer info->name already present\n!"); 655 mp_msg(MSGT_DEMUX, MSGL_WARN, "Demuxer info->name already present\n!");
655 return(0); 656 return(0);
656 } 657 }
657 info->name = malloc(strlen(param)); 658 info->name = strdup(param);
658 strcpy(info->name, param);
659 return(1); 659 return(1);
660 } 660 }
661 661
662 if (!strcasecmp(opt, "author")) 662 if (!strcasecmp(opt, "author"))
663 { 663 {
664 if (info->author) 664 if (info->author)
665 { 665 {
666 mp_msg(MSGT_DEMUX, MSGL_WARN, "Demuxer info->author already present\n!"); 666 mp_msg(MSGT_DEMUX, MSGL_WARN, "Demuxer info->author already present\n!");
667 return(0); 667 return(0);
668 } 668 }
669 info->author = malloc(strlen(param)); 669 info->author = strdup(param);
670 strcpy(info->author, param);
671 return(1); 670 return(1);
672 } 671 }
673 672
674 if (!strcasecmp(opt, "encoder") || !strcasecmp(opt, "software")) 673 if (!strcasecmp(opt, "encoder") || !strcasecmp(opt, "software"))
675 { 674 {
676 if (info->encoder) 675 if (info->encoder)
677 { 676 {
678 mp_msg(MSGT_DEMUX, MSGL_WARN, "Demuxer info->encoder already present\n!"); 677 mp_msg(MSGT_DEMUX, MSGL_WARN, "Demuxer info->encoder already present\n!");
679 return(0); 678 return(0);
680 } 679 }
681 info->encoder = malloc(strlen(param)); 680 info->encoder = strdup(param);
682 strcpy(info->encoder, param);
683 return(1); 681 return(1);
684 } 682 }
685 683
686 if (!strcasecmp(opt, "comment") || !strcasecmp(opt, "comments")) 684 if (!strcasecmp(opt, "comment") || !strcasecmp(opt, "comments"))
687 { 685 {
688 if (info->comments) 686 if (info->comments)
689 { 687 {
690 mp_msg(MSGT_DEMUX, MSGL_WARN, "Demuxer info->comments already present\n!"); 688 mp_msg(MSGT_DEMUX, MSGL_WARN, "Demuxer info->comments already present\n!");
691 return(0); 689 return(0);
692 } 690 }
693 info->comments = malloc(strlen(param)); 691 info->comments = strdup(param);
694 strcpy(info->comments, param);
695 return(1); 692 return(1);
696 } 693 }
697 694
698 if (!strcasecmp(opt, "copyright")) 695 if (!strcasecmp(opt, "copyright"))
699 { 696 {
700 if (info->copyright) 697 if (info->copyright)
701 { 698 {
702 mp_msg(MSGT_DEMUX, MSGL_WARN, "Demuxer info->copyright already present\n!"); 699 mp_msg(MSGT_DEMUX, MSGL_WARN, "Demuxer info->copyright already present\n!");
703 return(0); 700 return(0);
704 } 701 }
705 info->copyright = malloc(strlen(param)); 702 info->copyright = strdup(param);
706 strcpy(info->copyright, param);
707 return(1); 703 return(1);
708 } 704 }
709 705
710 mp_msg(MSGT_DEMUX, MSGL_DBG2, "Unknown demuxer info->%s (=%s)!\n", 706 mp_msg(MSGT_DEMUX, MSGL_DBG2, "Unknown demuxer info->%s (=%s)!\n",
711 opt, param); 707 opt, param);