none
Operação aritmética resultou em um estouro RRS feed

  • Pergunta

  • Olá Pessoal,

    Quando passo uma string passa normalmente, sem erros. Quando passo uma outra dá estouro de memória, e a string é menor que a primeira.

    Strings:

    String do erro:

    a39d13a9b69c3ef06b8066e9ea8ad46563cc7c5fb38deb661f1f1ba932c35dbaed2e1fb7b46980994b7a2b76c56727418037db25ef2408f09d215f20c0be805801ccfde8a701bbc7523ac4b7a050223187f541e571e3125d7296b0b521db4910204f7b5f938415d01eb78a6c51a649d7d65de1f72f0014caa3ae8dc56ddc423be6caaa6f5c9db375df7ad1444a8598cbcadcb864bede5a24cca43953d512dde27c673fac5b8f0c77e9524e8743fe80efe7ff5509894bd6d47565527253b679402bedd881032a08507525707723868d8e0aa44fcf327189e2a8a5977a2251a5d06909435f50b1aa66d1398548e87a9b030374c717f6697fdb64ae9b3e7a0430692931f845e6ebb16f18e85e9e1e72d0dd5364ddf20288642040d1e7517b2aac5e480e027463c00001ca30fe9a17402b0af986a1fb867eb10dd01c5f87a7b26c884b2a3e8a0322129a2e73814968819d1264570839640f01fa3e76ae01060850da1cd283b302529fe279c0d8970169438ec869435c32d140973b255af29acd02121777a97b06988dbab3eb90b864fdc3f224de48f3123a5164436bd524f416b802ba44544a82d9726f77d21ca05b923e2a3268a4840e92501c5fca96dcdb9d0401763531da907369290050d6e1d4bb4172234180fc29b2964a503b0902bc19654a24e40ae8d23cd394a83629c80bb64ff334d588b1912040d91e74e18087f7b200e4ce054ba5ec180902bcd9d48648111a72dfca8dcd7284863c084bd84910e03b43fe0e01f2e0e4eaa049a4b020eb300c82937712047833047d271d05dc731e372e31296a4fbc72cbe2f5b4841b175f3696aa9932120428abadba2d8087480692d0fc554d6bd9486a99d0022aa05afe6a36a718e0bc84c4c587bc162d60274dcef2c6c5ad229f02b48b0aaa2f8b54fad113e07c2bb78d4b9655df8d183be9b312b69d4280f357c0c675f33cdc4910e0709627ae80e1905569ce9e007310d4b48446b67273a52c1291d6e9f25c1b97547c764d2a91d61578ce79d397b06893b2dabbbbb9c0899deba68960274180f23cdc1351771204285f0e6da7100902948dd28484b379a31b972c30eb39e00f089007786b76da5875bebffe7cbbbcbcfcfef576cc41b371c98e57a66e3d224180a2a90d55966424085096b3f61cf01b04c875bd5034a99d0401f259767c52566852645a539480c8a4883a4be9dde0ea4e2112042827657714ee24085076955dcaeb2b93204099a5eeda3774d0a4f4a67b5d4f6c224180d295e9cafb30932040696957e57d984910203f0fab936b274180fcf5e58b4f8a48019a14a9de8af3304093327014ee240890ef14da7a0b2341807c52d6526a6f2741806c52c8fb51bf215575bb7f7efafdf6a1cb9f037655dd6c028c8c04018eae00224180b240445b8764fc9c078caa0bd36ab71e912040beb057b66c88340548018d8b4c34680573d24d1093f2981eb08fd76fd7fb8f30ab84c475332c61274180032dc05029e6a918cec2c5dfd82e491819090294c5afaa026eac06760a7149639a6e8006021493923b0dedd7a8712b354a7b7bfe3fea6ef6f37ded67efaf479ebd340d277e2fabb253a898edfd51c026a137dddba62a3e9934059823759ded42ddeae160a8ca2520e1da652e54b5c2444f615a8fcfdf3f0a8f1480d1cb75481e1546820007aa59da32a5d0f1c7bf0a485c038d3e9320407e6287b40e35231d05dc357aed9cac752f25d4d090f5e8f8ca2408f0a64f6a274180f2a277e5c4ce240890bfbe2856c432d21c603ab0d755049f340f38011a4842f39775ce30122061e86ebdb59c87eb62a159b65d369c6d125a6896ededf25c3b0902bc59ab8a4811da2971bc5322f40de378a744e81b0edc1f3b09021caec338bb0e772e9998df26454127b61a9fd80a3ab1d572db27b59320c081469f4910e06852d4824c4ae2e2018db64968491ba57ef4e787cbf5e5583ac9c6d577a264800f10e0401bcd2408f066d86a2245323bff732aad6f5f4fafd79fe7c7ebffde078c6b17b6aacbeb8b727ce8b17428aea302baeed11e4ae6c24e8200f9a424b8f21471363d2aa6df87c4259f73f549ec1ce2d7232e3929d520994910a068ae54927977120428edd8f5d67380d37fe31a9c36390a6e5a7974a18f731080f3ea2d71f103362ca1b8903ce442f29d0b8949984910209f1432f7ed0bdb3b759ef7f8242ee14fa9398f3b09021c0dd923fe65ef0761ab8944b9b7f38032f7367d4353f6b20f2ba8eb493da56ebd603470a71017975035635a264180d20d570de3217b1eabcde1fafdbdacb85d0157abf2ae4b5eabafaf4091d5d3072c71f159e612523cf6b4dd86b8b875aee656ec240850aec3c8011f20406eb721fbe1beb0a95ff66c20d9c6d51510ab93e2e603c9362ee9286c43a634340030deceadd84910a0e844597ac3251235649907f46af80d3d72da1057df7321321204281b3a2f75d9780d49a8879302054105df9b5954b139e4f0e9f99d22c3a7b95137932633fdddaaad3011d093bd2e1b7a121f053c6dc1c91b97ac075bdfd899343fe438a8724963d7e91bcebe6d886b604ccb2408f0667eca4e820045e59366838d8b07960d71f12079f29a19468200859e423d51196906907ac32deb2adb3f51d5f23264934eb679098dbc469766698f6b52cdee7effef3a07b81a199cdcc205330902bc99e6b9932040e1792c2d12761204284d556b798a44aa1002000ae742d2a4629b94159a94bf1570c34810a0b8029400442645b883d55aaa25ec2408b0ef275526853240a921efdb31c0b47ead5bd2cd61f5895da325047d03bc9b0064623009594410b53c9b5c368e92e665514a16fa4be1eee76947614e4f38f1855d1fed9174a2e9477b94458724a006b400e27a1801ce3a0a0b9790902dec9814f0fffc3e3fbc5013add7b797df4f49d77dbedde5a50146a180ab582f29aac0918d69e9e6bb4beae3f9f7dbf3d3f9bdf6a02f697ce90a11319ce49ed9157045dedbb96a5a858bdf7aae866929f28cdc3dfefedfe9e1520c7de7a1b2476eb83f5e2daaf3a7b04949a408018a9d424eae7d612b6ff2bdfc5145a96ec8c425ed877bd343a78249437e7ebc1caa9670da9f73998b032ea5fff24e3a0a5825242e7e2fbb9285b49310099f6465bccf03fee293124a098bfd6f21437e92398f9e031e9e94edb1a455887ae902bc031bf22f48c25f5c420a31b285148f2f1b062892caa95b535b36115a36519e876acf86db49c02cc727b197bf00502c1b6af2c5867cf9ec90d3c6f35b25a85d780490afc3dcfadc30d2fc3a947dcde839d7d66184d661fc255433a5ea3aa4e7dc3ca07cce65f536321204c8bd158afc688c84008a65a3d969b3aec82c272e6922f01c10396d5417e7a0182032cb898bdfcb912d1b2241805d7b50e5180902eca29df737f6469a3f1c1297343bc7b60e2db4b06d178f6dda37b4d0c2969d79a9ee9c612460c8f64968f45f00c8778a52ecf8a2bf850cf9a95f870c10390f555794920f19da29f6575f0c50311204d877d6b08c0401cab477b3abb72a504acefc2c7729398a5da3449a97b0cba0d1ecf8221202284e6c2a16dd2444d6a1ed6b8caf4cc2b965e3a85b9f5dc545df4afa2440af112dc0eba11640a4f9214b4b7bf62f2f8c8448f824b7dee70187cf39ca44feec90d3355ab5d12c3c02288faf52f271274d1f5fb900cb89bf1c9a5a415f0391501c5f96acb099443114147cb205db1c9370d151b99102aea93edb1d2d44cafcb8bcde9f7f7d54b1961a1078bd0cbc153ab7497aa4ccd6039533778d5e652e69c4608011029426022a4a697640aa9cfcebfcf8e3f2763e3d5e09786c022b9392b96e56f0de4910205fd84979dc5f5f7a55d30d9dadf3548a993fe774f50568aa757ff7cff7d3ebf9d7f9edfc4edbf31d70b7d0135f0324df4201746699df7a99abafa96b180978638b9a69ba6d3d029cdf7a994b5ada8b7a9b4813d7e8693f0f89eb49ea7a9f071407ac57ba4d0a708d662ea9f8b04951d073ee9d4999bc972b179f14d7ce4367802b207389aabf7cc8d815f0ce90812b207349cf636ccb06d00288eb499a4c3f0f28d58a76da24d20519b2bdf0219bd27361171e011417fd9a24348c049c36ebb97f2c29f63510097f49cb92009cd6533297d4e8f74af23b0902945104a14d8a8366d98d67d941b3ecc6c797838eaf75bc971d34cb4e1e5f12109965f74b1461239708234180521b0df570a0a4f27940ebc425458d3516463a0a48cfb9ac9a39a9a7b41a924efbdc8c78ae9cf5c6c583e4a98fcfa680ebe07229e69727f247d546391f011297b4db9403363d3de9c17979381f714a15c0cc250acc4ac07b08b08b69af80d64f578fd9b8de019cadddb77149639aaf801ea80495b9642a846980fefc631230ae6bd72241552d209d8cfafc0400f6fd532a20b548f8670e3038bb4a27179f14b5a659bebb5e1ecfa78fab8c372d80f8068036a9666fd7978fbce97cc81b972c81db00a9a6eeb7cbfd8ff3c3ef8f629319a0aca99bfd7a9691204071eb551341227908d077de5bbdfb978da188f1bbf3db65ea1b12d7e070c8240870b097570ae2fd75be9253fdd7cbf5e7fdf5d7f8e0a980c4d56dbd3dcec1384725ce9eff7b7d4aa7c3f97514e1d00112973004a5bdb24be868c85b35ad8fdb613440396496ac613ca5ff3c3d934de4f5f274a5760e64211903be3c16aedbdf30677fccd6fb327db2462b6e60729cc39489204d80a72b607038f8ad80d84bbaf84e1f5ecf4dc22e90ac364a2352dae64dc274195cc6275995d09bbff2e8cbd6f316a89996b984a9aaeacb861243eeee9e9feece276ae77314b02b81cb4e6c1f4b6fb863bfc2a5bf1a50758743bd463369b2f7c7c6355ad83177787979b95ccfa7b77413bc3e5d5f5f072b9201daee3c0c6561e7c08939dbd7ce35f886c1518df18312d66f485cf21b86fdc16902d583fd7579f9767d3ca72bf42e419fd37df09184b21e2cff86b99ef93c60189e369904010e24cce5ac279b1e6e5cb703bcd7850abfcfd8b12bd73b80f710e0ed84e88d0401cac24d455f5ea90ee7ddebe5e7874d8104a09211e354aa8a03de43805cd75b6b3d8755531fbaf42efcfefbe3cc30f63e243e06a86b80f76a140df9fa78496f86e78f1a335609894b96b3deaba02712f519990734aaf35694c24d1b0902944f9152d56d234180326fb4e4f824526e7a38e1a0d9b8643bbc950fd97d1ed02c8b8bbe90924ef4fd255dccc7fbebb9d54aa73fc5dcb76f1820094570327321ad86a2ee7f3d9efff3fbf2714476035cfbcebc258a2091fcfc7998b9f8d6e30b9b4810a08c6937ca37d2e19ead23c0dca3d0eca4a4139d675f0e994bb499a0fa318d748100658da0e24f49a478fcb1c400a536da014e3f9632d7cda2e58944995cf3931265e682aa65911269fa5e0e917a00ca3776ba54cab289619fe53940594d4b48182009454316091821c0ae074d6977e2562a2d8500ae7dff9472da5059a4eb64976db7527032ab2bc27cf42b55317a380a78da5fb0994bd6d4f58b66a42940bb4413943055c1807b79ae04d8f552ff2c609ac92f94d051a13e2f5372e8c45605302d6ccaa33f723ad4595e65d343ca52df8bbd6ca449c0a073665003a490a5f2faa2f2418884f23c5c6bd5df8d0448280e077e1eae2a1e3f6d4e7561ab38c8425a579db480b797e72d679432b0de791ab7216b33481ada4810207fce51b11757486eeab4d9263306c36db02c70625d5707dc29c4c52f29da29651d52f368ea877d495af23b583de05fa554ea37747ede6e93b9a47aabaa847e210be7cb873a8a04f4b2569555c506bb5aaa7f38bd53acac7f489a5e1972264180bc028f92127e3b0a782a3ba597903d89d33fa1214b3d857e869120409ea2184a0feb8d7478c82309f9696355bae89f9e7fbe1d7157b4e3ab4b7be743a606f747014f7552941aa915990448683ac050bfe1baa4037676eb11970c9f2ef6c3d59216f08b24a48cbdcbf5bf47fc7a996b08e821403fba021c952c3eaa809fcaa410d73b80f33607e2bad9b69b48eeb8840cb057c0052022a1b463b79a181b09021c5ca3993407687dee61cdbd15b1162aa1de7662c8afbf7f3d5e9e2e3f47988d4b4c8aaae761261d056443f67dd47d512b1cd9b1ef9f7ffeb9bcbce6a7c3dbf9f1fa5e326fe51a2d1b4abcca177d36899c73b2f1fbdf70e7124f1136cb49d9bf7fb8befeca833d51c3f2d3b797cb6dbf190394460c57cbc46d2408909fd894a55e00ad3a6e7338d559b6c303d6d9f4e04cc23dbf4cf84633d73b8077538014ac1357d525a216dfe8ea5c5af347dd1f6dc84e76f38cd55b9148265d52545ae4a8ed2bbd1a8296e5b9281bae4a48a4a366e726a1975740ebe3b39120c07ea754093d24a1ef8a6cd826e184e95e00caf2fe6bb17d65d2b4e99eb8069625af102d80b8de019c374812d77701580227361204c83de0ece59049102033b3f027b1a7a8fbcd1d3c61b7212e11cda2541b7284be61949169cd644a6917f32ea42e5983df299e725401c0bedb7b6c122a4842d9a9bcd5905cbd2d76ecebcfa4873ffc7eef542caddcac33aeb3db7c0270b3ce89e3eb93126a1f9cd163098bd9f90060fb8656166eea001f2040792fd73b2593806fe8bb65f309c01bb32c00d385f8e959fe1ce0974b7863d9701792f76a2b71f6ebfcf2e1c3a1cdb25723d52c9320c0c15e0eba44b3ccacc3303e1c32090294c127a5bf5e2205484279055096ba622408b097709fe5401e707a595f1f47011db7003b0f38d5fbda8d698194fd695d8fb864dc5729109148691da62573fef6fb63f59b01aa917a1b560d68a3c435d046330902bc5dab6a234180b7cb5927126a1591b559aa2f20b85c406c1804740b306863e2206f74cde525a7c363888b8718ad2dce219320c0ce1ddc247440441071c932c2f53ccc240850984c9b3f855c7e737ebdcd0dd787a063802337dca7017b37dce7006fb8e1b8dd866ae9ccdb6d884bd86d6a01b135a7ff3c5c5fef9fc7b68b5b80eb28f82493a6

    Métodos:

            public static string DecompressString(string compressedText)
            {
                byte[] gZipBuffer = ConvertHexStringToByteArray(compressedText);
    
                using (var memoryStream = new MemoryStream())
                {
                    int dataLength = BitConverter.ToInt32(gZipBuffer, 0);
                    memoryStream.Write(gZipBuffer, 0, gZipBuffer.Length);
    
                    byte[] buffer = new byte[dataLength];
    
                    memoryStream.Position = 0;
                    using (var gZipStream = new GZipStream(memoryStream, CompressionMode.Decompress))
                    {
                        gZipStream.Read(buffer, 0, buffer.Length);
                    }
                    return Encoding.UTF8.GetString(buffer);
                }
            }
    
            public static byte[] ConvertHexStringToByteArray(string hexString)
            {
                if (hexString.Length % 2 != 0)
                {
                    throw new ArgumentException(String.Format(CultureInfo.InvariantCulture, "Não pode possuir um número ímpar de dígitos: {0}", hexString));
                }
                byte[] hexAsBytes = new byte[hexString.Length / 2];
                for (int index = 0; index < hexAsBytes.Length; index++)
                {
                    string byteValue = hexString.Substring(index * 2, 2);
                    hexAsBytes[index] = byte.Parse(byteValue, NumberStyles.HexNumber, CultureInfo.InvariantCulture);
                }
                return hexAsBytes;
            }


    sexta-feira, 12 de maio de 2017 12:43

Respostas

  • Boa tarde Yannick Freitas,

    Vejo que você está usando Int como tipo da variável.

    O valor máximo de um integer é 2147483647, esse erro normalmente acontece para evitar comportamentos inesperados na aplicação.

    Se você deseja valores maiores, use a declaração da varável como int64, visto que o valor será aumentado para: 9223372036854775807


    Att., Roberto Alves

    Por favor, lembre-se de Marcar como Resposta as postagens que resolveram o seu problema. Essa é uma maneira comum de reconhecer aqueles que o ajudaram e fazer com que seja mais fácil para os outros visitantes encontrarem a resolução mais tarde.

    sexta-feira, 12 de maio de 2017 19:57