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

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: Removed long lines and brackets 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
« no previous file with comments | « base/third_party/xdg_mime/free_pointer_later.patch ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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)
565 return mime_type; 564 mime_type = _xdg_binary_or_text_fallback(data, bytes_read);
566 565
567 return _xdg_binary_or_text_fallback(data, bytes_read); 566 free (data);
567 return mime_type;
568 } 568 }
569 569
570 const char * 570 const char *
571 xdg_mime_get_mime_type_from_file_name (const char *file_name) 571 xdg_mime_get_mime_type_from_file_name (const char *file_name)
572 { 572 {
573 const char *mime_type; 573 const char *mime_type;
574 574
575 xdg_mime_init (); 575 xdg_mime_init ();
576 576
577 if (_caches) 577 if (_caches)
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
925 const char * 925 const char *
926 xdg_mime_get_generic_icon (const char *mime) 926 xdg_mime_get_generic_icon (const char *mime)
927 { 927 {
928 xdg_mime_init (); 928 xdg_mime_init ();
929 929
930 if (_caches) 930 if (_caches)
931 return _xdg_mime_cache_get_generic_icon (mime); 931 return _xdg_mime_cache_get_generic_icon (mime);
932 932
933 return _xdg_mime_icon_list_lookup (generic_icon_list, mime); 933 return _xdg_mime_icon_list_lookup (generic_icon_list, mime);
934 } 934 }
OLDNEW
« no previous file with comments | « base/third_party/xdg_mime/free_pointer_later.patch ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698