Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(96)

Side by Side Diff: base/third_party/xdg_mime/xdgmime.c

Issue 1037023002: Do not free pointer when you are going to use it (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Code according to suggestions Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* -*- mode: C; c-file-style: "gnu" -*- */ 1 /* -*- mode: C; c-file-style: "gnu" -*- */
2 /* xdgmime.c: XDG Mime Spec mime resolver. Based on version 0.11 of the spec. 2 /* xdgmime.c: XDG Mime Spec mime resolver. Based on version 0.11 of the spec.
3 * 3 *
4 * More info can be found at http://www.freedesktop.org/standards/ 4 * More info can be found at http://www.freedesktop.org/standards/
5 * 5 *
6 * Copyright (C) 2003,2004 Red Hat, Inc. 6 * Copyright (C) 2003,2004 Red Hat, Inc.
7 * Copyright (C) 2003,2004 Jonathan Blandford <jrb@alum.mit.edu> 7 * Copyright (C) 2003,2004 Jonathan Blandford <jrb@alum.mit.edu>
8 * 8 *
9 * Licensed under the Academic Free License version 2.0 9 * Licensed under the Academic Free License version 2.0
10 * Or under the following terms: 10 * Or under the following terms:
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 if (ferror (file)) 551 if (ferror (file))
552 { 552 {
553 free (data); 553 free (data);
554 fclose (file); 554 fclose (file);
555 return XDG_MIME_TYPE_UNKNOWN; 555 return XDG_MIME_TYPE_UNKNOWN;
556 } 556 }
557 557
558 mime_type = _xdg_mime_magic_lookup_data (global_magic, data, bytes_read, NULL, 558 mime_type = _xdg_mime_magic_lookup_data (global_magic, data, bytes_read, NULL,
559 mime_types, n); 559 mime_types, n);
560 560
561 free (data);
562 fclose (file); 561 fclose (file);
563 562
564 if (mime_type) 563 if (!mime_type) {
Lei Zhang 2015/04/20 19:14:02 No need for braces. The rest of the code only use
gburanov 2015/04/22 14:21:55 Done.
565 return mime_type; 564 mime_type = _xdg_binary_or_text_fallback(data, bytes_read);
565 }
566 566
567 return _xdg_binary_or_text_fallback(data, bytes_read); 567 free (data);
568 return mime_type;
568 } 569 }
569 570
570 const char * 571 const char *
571 xdg_mime_get_mime_type_from_file_name (const char *file_name) 572 xdg_mime_get_mime_type_from_file_name (const char *file_name)
572 { 573 {
573 const char *mime_type; 574 const char *mime_type;
574 575
575 xdg_mime_init (); 576 xdg_mime_init ();
576 577
577 if (_caches) 578 if (_caches)
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
925 const char * 926 const char *
926 xdg_mime_get_generic_icon (const char *mime) 927 xdg_mime_get_generic_icon (const char *mime)
927 { 928 {
928 xdg_mime_init (); 929 xdg_mime_init ();
929 930
930 if (_caches) 931 if (_caches)
931 return _xdg_mime_cache_get_generic_icon (mime); 932 return _xdg_mime_cache_get_generic_icon (mime);
932 933
933 return _xdg_mime_icon_list_lookup (generic_icon_list, mime); 934 return _xdg_mime_icon_list_lookup (generic_icon_list, mime);
934 } 935 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698